Push Notification
#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v)([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]!= NSOrderedAscending)
In AppDelegate class method didFinishLaunchingWithOptions you have to use Code --
if ( SYSTEM_VERSION_LESS_THAN( @"10.0" ) )
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
if (optind != nil)
{
NSLog( @"registerForPushWithOptions:" );
}
} else {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
if ( !error )
{
[[UIApplication sharedApplication] registerForRemoteNotifications];
// required to get the app to do anything at all about push notifications
NSLog( @"Push registration success." );
} else {
NSLog( @"Push registration FAILED" );
NSLog( @"ERROR: %@ - %@", error.localizedFailureReason, error.localizedDescription );
NSLog( @"SUGGESTIONS: %@ - %@", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );
}
}];
}
And Add the following framework -
Hello, an amazing Information dude. Thanks for sharing this nice information with us. IOS Developer
ReplyDelete