2012-07-06 2 views
0

작동 시나리오 : 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 분배에서 장치 토큰을 통해 진행하도록받을 수 있나요? 감사.

답변

1

this question about push notes을 찾았을 때 관련 질문을 열람하고있었습니다. 나는 그 생각을 생각하고 처음부터 끝까지 물건을 체크 아웃하기 시작했다. 그것은 나에게 있다는

Apple Push Notification Developer View

잘하면 문제가 당신에게로 분명하지만, 그렇지 않은 경우 이해 : 나는 마침내이 발견했다. 프로덕션 푸시 SSL 인증서의 상태가 Enabled 인 경우를 제외하고는 APN이 IPA와 함께 작동하지 않습니다.

1

Xcode install은 개발 버전이며, .ipa는 프로덕션/adhoc이며 다른 인증서가 있습니다. 원격 알림 가이드를주의 깊게 읽으십시오!

+1

나는 이미'release' 수준의 인증서를 만들었지 만, 내 인증서가 틀린 경우 내 장치가 토큰을 전혀 내놓지 않는 이유는 무엇입니까? – Jacksonkr