작동 시나리오 : xcode에서 내 장치로 직접 응용 프로그램을 실행할 때 서버에서 푸시 알림을 실행할 수 있으며 예상대로 작동합니다.푸시 알림 불일치
작동하지 않는 시나리오 : 앱을 IPA로 내보내고 iTunes를 통해 내 장치에 앱을 설치합니다. 내가 서버에서 알림을 누르면 내가 생각을했다하고 설치 IPA 대 설치하고 서로 다른있는 엑스 코드에서 왔을 때 디바이스 ID를 확인이 게시물을 쓰는 동안 나는
ERROR: Unable to send message ID 1: Invalid token (8).
의 오류가 발생합니다! 내 서버에 장치 ID를 전송하는
코드 :
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// You can send here, for example, an asynchronous HTTP request to your web-server to store this deviceToken remotely.
// convert token to a 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 from server: %@", dict);
});
}];
NSLog(@"Did register for remote notifications: %@", deviceToken);
}
어떻게 그것은 IPA 분배에서 장치 토큰을 통해 진행하도록받을 수 있나요? 감사.
나는 이미'release' 수준의 인증서를 만들었지 만, 내 인증서가 틀린 경우 내 장치가 토큰을 전혀 내놓지 않는 이유는 무엇입니까? – Jacksonkr