Je travaille sur la fonctionnalité de notification push d'iOS par le biais de la notification push d'apple, pour l'instant je reçois une notification appropriée lorsque mon application est en arrière-plan ou au premier plan, mais je veux gérer la notification à distance lorsque mon application est en arrière-plan fondamentalement, lorsque mon application est en arrière-plan, elle montre simplement le message d'alerte de la charge utile.
code :
- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
// Override point for customization after application launch.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
// [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
return YES;
}
- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Did Register for Remote Notifications with Device Token (%@)", error);
}
- (void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken {
NSLog(@"Did Register for Remote Notifications with Device Token (%@)", deviceToken);
}
-(void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(void (UIBackgroundFetchResult))completionHandler
{
NSDictionary * aps=[userInfo valueForKey"aps"];
NSLog(@"did recevie %@",aps);
NSLog(@"userinfo details %@",[aps valueForKey"alert"]);
}