ios - Method not being called: - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken -
been stuck on forever, not following methods called. able phone ask permission after gets stuck.
- (void)application:(uiapplication*)application didregisterforremotenotificationswithdevicetoken:(nsdata*)devicetoken { nslog(@"my token is: %@", devicetoken); } - (void)application:(uiapplication*)application didfailtoregisterforremotenotificationswitherror:(nserror*)error { nslog(@"failed token, error: %@", error); } i have tried quite few things including:
1) offered in following stackoverflow post: why didregisterforremotenotificationswithdevicetoken not called
2) looking @ technical note apple: https://developer.apple.com/library/ios/technotes/tn2265/_index.html
3) entire tutorial: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 (so certificates good)
4) (and yes have internet connection)
does have possible solutions? have been rattling brains out last 2-3 days , have had factory reset phone twice, change date on phone n^e number of times in order notification popup appear test on , on again.
would love help! thanks!
here using call... (tried few other versions):
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { //other stuff not related if ([application respondstoselector:@selector(registerusernotificationsettings:)]) { #ifdef __iphone_8_0 uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:(uiremotenotificationtypebadge | uiremotenotificationtypesound | uiremotenotificationtypealert) categories:nil]; [application registerusernotificationsettings:settings]; [application registerforremotenotifications]; #endif } else { uiremotenotificationtype mytypes = uiremotenotificationtypebadge | uiremotenotificationtypealert | uiremotenotificationtypesound; [application registerforremotenotificationtypes:mytypes]; } return yes; }
ios 8 introduced change in flow of registration requires explicitly asking register remote notifications after getting permission user.
you calling code?
[[uiapplication sharedapplication] registerusernotificationsettings: settings]; and implementing in application delegate?
- (void) application:(uiapplication *)application didregisterusernotificationsettings:(uiusernotificationsettings *)notificationsettings { [application registerforremotenotifications]; } that said, old apis deprecated still required if plan support ios 7. support both can check see if uiapplication responds new selector:
if ([[uiapplication sharedapplication] respondstoselector:@sel(registerusernotificationsettings:)]) { // ios 8 [[uiapplication sharedapplication] registerusernotificationsettings: settings]; // [[uiapplication sharedapplication] registerforremotenotifications] // called in uiapplicationdelegate callback } else { // ios 7 [[uiapplication sharedapplication] registerforremotenotifications]; }
Comments
Post a Comment