0

저는 처음에는 iphone 기술에 익숙합니다. 지금은 밀어 넣기 알림을 구현해야하는 응용 프로그램과 작업하고 있습니다. 또한시뮬레이터에서 장치 토큰 요청에 대한 응답이 없습니다.

http://mobiforge.com/developing/story/programming-apple-push-notification-services#comment-7850

, 다음 코드를 사용 :

나는 링크를 따라

NSLog(@"Registering for push notifications..."); 
    [[UIApplication sharedApplication] 
    registerForRemoteNotificationTypes: 
(UIRemoteNotificationTypeAlert | 
    UIRemoteNotificationTypeBadge | 
    UIRemoteNotificationTypeSound)]; 

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 
{ 
    NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken]; 
    NSLog(str); 
} 

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err 
{ 
    NSString *str = [NSString stringWithFormat: @"Error: %@", err]; 
    NSLog(str);  
} 

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{ 
    for (id key in userInfo) 
{ 
     NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]); 
    }  
} 

것은 내가 프로그램을 실행할 때, 내가 디버거 창에서 장치 토큰을 받아야한다 코드별로 다음과 같은 오류가 표시됩니다.

" Error in registration. Error: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo=0x6e055a0 {NSLocalizedDescription=remote notifications are not supported in the simulator} "

어떻게이 문제를 해결해야합니까?

친절하게 도와주세요.

감사합니다.

답변

4

시뮬레이터가 지원하지 않으므로 ... 예에서는 콘솔에 장치 식별자를 표시합니다. 콘솔에 장치의 피드백이 표시됩니다. 정보를 얻는 콘솔은 아니지만 정보를 보내는 장치입니다. 따라서 콘솔이 Mac에 정보를 표시한다고해서 Mac이 해당 정보를 직접 가져올 수있는 것은 아닙니다. 때로는 장치에서 전송해야합니다. 장치에서 실행 해보십시오.

+0

좋아 .. 나는 그걸 모르고 있었어. 설명에 대해 언제나 고마워. – Sarah

+0

나는 Madhup의 답변 후에 이것을 게시했다. 디버그 콘솔이하는 일에 대해 혼란 스러울 것 같기 때문이다. – Beaker

+0

예, 모두 혼란 스러웠습니다. – Sarah

4

오류 메시지가 자체적으로 설명하는 것이므로 푸시 알림이 시뮬레이터에서 수신되도록 지원되지 않으므로 시뮬레이터가 아닌 실제 장치에서 앱을 디버깅해야합니다.

+0

사실입니다.하지만 내가 언급 한 링크를 확인하면 표시된 예제에서 토큰 번호가 디버거 자체에서 가져옵니다. 또한 같은 것을 가져 오는 방법은 무엇입니까? – Sarah

+0

@Sarah 모든 장치에서 디버그하십시오. 시뮬레이터에서 푸시 알림을 테스트 할 수 없습니다. –

관련 문제