push notifications iOS add device -
i new iphone , when tried test xcode project push notifications , doesn't token , failed token , think because when creating certificate didn't mark on device , want add device testing , token should ??
- (void)application:(uiapplication*)application didregisterforremotenotificationswithdevicetoken:(nsdata*)devicetoken { nslog(@"my token is: %@", devicetoken); } - (void)application:(uiapplication*)application didfailtoregisterforremotenotificationswitherror:(nserror*)error { nslog(@"failed token, error: %@", error); }
for should first set provisioning profile in have added device udid. add below code register pushnotification in device. when run app first time ask permission .
//push noti [[uiapplication sharedapplication]registerforremotenotificationtypes:(uiremotenotificationtypealert|uiremotenotificationtypebadge|uiremotenotificationtypesound)];
if allow below delegate called. , give device token.
-(void)application:(uiapplication *)application didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken { nsstring *strdevicetoken = [[[[[devicetoken description]stringbyreplacingoccurrencesofstring: @"<" withstring: @""] stringbyreplacingoccurrencesofstring: @">" withstring: @""]stringbyreplacingoccurrencesofstring:@" " withstring: @""]copy]; nslog(@"%@",strdevicetoken); }
if dont allow below delegate method called
- (void)application:(uiapplication*)application didfailtoregisterforremotenotificationswitherror:(nserror*)error { nslog(@"failed token, error: %@", error); }
maybe you.
Comments
Post a Comment