ios - push notification inconsistencies -


working scenario: when run app xcode directly device can run push notification on server , works expected.

non-working scenario: export app ipa , install app on device via itunes. when push notification server i'll error of error: unable send message id 1: invalid token (8).

while writing post had thought , checked device id when came xcode install vs ipa install , different!

code sending device id server:

- (void)application:(uiapplication *)application didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken { // can send here, example, asynchronous http request web-server store devicetoken remotely. // convert token single string nsstring *token = [[[devicetoken description] stringbytrimmingcharactersinset:[nscharacterset charactersetwithcharactersinstring:@"<>"]] stringbyreplacingoccurrencesofstring:@" " withstring:@""]; nsstring *post = [nsstring stringwithformat:[nsstring stringwithformat:@"token=%@", token]]; nsdata *postdata = [post datausingencoding:nsasciistringencoding allowlossyconversion:yes]; nsstring *postlength = [nsstring stringwithformat:@"%d", [postdata length]]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:@"http://mywebsitename.com/apnsphp/add.php"]]; [request sethttpmethod:@"post"]; [request setvalue:postlength forhttpheaderfield:@"content-length"]; [request sethttpbody:postdata]; [nsurlconnection sendasynchronousrequest:request queue:[[nsoperationqueue alloc] init] completionhandler:^(nsurlresponse *response, nsdata *data, nserror *error){ dispatch_async(dispatch_get_main_queue(), ^{ nserror *e = nil; nsdictionary *dict = [xmlreader dictionaryforxmldata:data error:&e]; nslog(@"response server: %@", dict); }); }]; nslog(@"did register remote notifications: %@", devicetoken); } 

how can device token ipa distribution goes through? thanks.

xcode install development version, .ipa production/adhoc, , have different certificates. read remote notifications guide carefully!


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -