Question

How can i delete a device with tag ,means i have ios Device Token and the tag that device registered with i need to delete this user from backend?

And also how i can access to list of users details like count by tag or /and device tokens that registered to azure notification hub?

Was it helpful?

Solution

In order to delete a tag you just update the registration with a set of tags that does not contain it. E.g.

SBRegistration* toUpdate = [hub retrieveNativeRegistrationWithError: nil];
[[toUpdate tags] addObjectsFromArray: @[@"myNewTag1", @"myOtherNewTag"]];
[hub updateRegistration:toUpdate];

Or Async:

[hub retrieveNativeRegistrationWithCompletion:^(SBRegistration* r, NSError* e) {
    if (r == nil) ; // error handling
    [[r tags] addObjectsFromArray:@[@"myNewTag", @"myOtherNewTag"]];
    [hub updateRegistration:r completion:^(SBRegistration* r2, NSError* e) {
        // error mgmt;
    }];
}];

Also, note that when you call createNativeRegistration you will overwrite the current set of tags. This naming inconsistency is getting fixed in the next release of the iOS SDK.

At this moment you cannot retrieve count by tag, but (from the back-end) you can retrieve all registrations with a tag (an inefficient a way to count). You can do it from the back-end .NET SDK, using:

var skip = 0;
var increment = 100;
IEnumerable<RegistrationDescription> regs = hubClient.GetRegistrationsByTag("myTag", skip, increment);
while (regs.Count() != 0)
{
    foreach (var i in regs)
    {
        // do work
    }
    skip += increment + 1;
    regs = hubClient.GetRegistrationsByTag("myTag", skip, increment);
}

Or using our REST surface: GetRegistrationsByTag

Thanks,

Elio

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top