ios - didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister...Settings is -
i followed this thread, method didregisterforremotenotificationswithdevicetoken
still not called :
the documentation says :
after call registerforremotenotifications method of uiapplication object, app calls method when device registration completes successfully
didregisteruser
appears well, not did register notif
.
here code in appdelegate (the app version 8.1) :
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { //register notif uiusernotificationtype usernotificationtypes = (uiusernotificationtypealert | uiusernotificationtypebadge | uiusernotificationtypesound); uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:usernotificationtypes categories:nil]; [application registerusernotificationsettings:settings]; return yes; } - (void)application:(uiapplication *)application didregisterusernotificationsettings:(uiusernotificationsettings *)notificationsettings { //register receive notifications [application registerforremotenotifications]; nslog(@"didregisteruser"); } -(void)application:(uiapplication *)application didfailtoregisterforremotenotificationswitherror:(nserror *)error { nslog(@"error here : %@", error);//not called } - (void)application:(uiapplication *)application didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken { /* // store devicetoken in current installation , save parse. pfinstallation *currentinstallation = [pfinstallation currentinstallation]; [currentinstallation setdevicetokenfromdata:devicetoken]; currentinstallation.channels = @[ @"global" ]; [currentinstallation saveinbackground]; */ nslog(@"did register notif");//not called }
i have background mode -> remote notification in info.plist.
your code seems correct. minor improvement write didregisterusernotificationsettings method so:
- (void)application:(uiapplication *)application didregisterusernotificationsettings:(uiusernotificationsettings *)notificationsettings { if (notificationsettings.types != uiusernotificationtypenone) { nslog(@"didregisteruser"); [application registerforremotenotifications]; } }
there may configuration problem causes failed apn registration.
assure provisioning profile contains aps-environment entry
assure have unique app identifier (a string without "*") set in provisioning profile. should use exact identifier "bundle identifier" in info.plist
maybe have declined push-feature after initial installation - in case never see in-app-push-alert again , have enable push in settings app again.
try device.
Comments
Post a Comment