Can you tell me the Difference between Push notification in IOS 7 and IOS 8, What is the new methods in IOS 8.
Asked
Active
Viewed 594 times
4 Answers
3
If you want to work for push notification in iOS 6,7,8 in all cases then use the following code snippet inside the didFinishLaunchingWithOptions
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
1
Add this on .m
file:
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
Then in didFinishLaunchingWithOptions
function:
if(IS_IOS_8_OR_LATER) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: (UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
//register to receive notifications
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
And now only for iOS 8:
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings: (UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
//handle the actions
if ([identifier isEqualToString:@"declineAction"]){
}
else if ([identifier isEqualToString:@"answerAction"]){
}
}
#endif
And then the delegate methods.
Taken from this link. This answer helped me with this. Hope this helps!!!

Community
- 1
- 1

Soumalya Banerjee
- 1,966
- 3
- 22
- 28
0
Vist following link, could be useful
http://corinnekrych.blogspot.in/2014/07/how-to-support-push-notification-for.html

Sanjay Mohnani
- 5,947
- 30
- 46
0
For new in iOS
notification
you can check out WWDC 2014
session 713
on this -
You can also download PDF file -

saadnib
- 11,145
- 2
- 33
- 54