ios - Devices are registered with token in Apple Push Notification but don't receive notifications from the server -
in app, have following process apns:
- register device in didfinishlaunchingwithoptions;
- receive token didregisterforremotenotificationswithdevicetoken;
- send notification server;
- my server sends notification;
- problem: device don't receive (didreceiveremotenotification never called on debug);
already checked app id on server , certificate.
anyone can point doing wrong?
appdelegate.m
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // checking if app running ios 8 if ([application respondstoselector:@selector(registerforremotenotifications)]) { // register device ios8 uiusernotificationsettings *notificationsettings = [uiusernotificationsettings settingsfortypes:uiusernotificationtypealert | uiusernotificationtypebadge | uiusernotificationtypesound categories:nil]; [application registerusernotificationsettings:notificationsettings]; [application registerforremotenotifications]; } else { // register device ios7 [application registerforremotenotificationtypes:uiremotenotificationtypealert | uiremotenotificationtypesound | uiremotenotificationtypebadge]; } //... return yes; } - (void)application:(uiapplication *)app didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken { nslog(@"registration successful, bundle identifier: %@, device token: %@", [nsbundle.mainbundle bundleidentifier], devicetoken); // receive token , send server } - (void)application:(uiapplication *)app didfailtoregisterforremotenotificationswitherror:(nserror *)err { nslog(@"error in registration. error: %@", err); } - (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { // handle notification }
Comments
Post a Comment