Reputation: 63
I would like to search for a particular push notification and remove it from the notification area. I want a code which looks something like this, except that it should work for remote notifications and not local notifications. Thanks in advance.
for (UILocalNotification *lNotification in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
if (![[userRecord valueForKey:@"User"] isEqualToString:[userInfo objectForKey:@"User"]])
{
[[UIApplication sharedApplication] cancelLocalNotification:lNotification];
}
}
Upvotes: 1
Views: 85
Reputation: 1003
In
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
if ([[userInfo objectForKey:@"User"] isEqualToString:@"Your user"])
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
//Do Nothing
return;
}
else
{
//process according to need
}
}
As Remote notification is sended from server so it can only be control at receiving end or from server end.I hope it will help.
Upvotes: 1
Reputation: 2494
If I understand you correct - you want to skip some remote notifications on your client. You can't do it that way. Your remote notifications are sent from apple server (usually through your server) and delivered to iOs system, then it will deliver to your app on iPhone or iWatch. In app you can use:
@available(iOS 8.0, *)
public func registerForRemoteNotifications()
@available(iOS 3.0, *)
public func unregisterForRemoteNotifications()
@available(iOS 8.0, *)
public func registerUserNotificationSettings(notificationSettings: UIUserNotificationSettings)
@available(iOS 8.0, *)
public func currentUserNotificationSettings() -> UIUserNotificationSettings?
You should make your own logic of sending remote pushes from your own server.
Upvotes: 0