0

Apple APN의 pushNotifications에 대한 새 프로젝트를 Firebase 콘솔에 만들었습니다. SSl 인증서를 생성하고 firebase와 프로비저닝 프로파일에 p12 인증서 (개발 및 프로덕션)를 업로드하는 것과 같은 firebase 문서의 모든 지침을 따랐습니다. 또한 Appdelegate에 필요한 모든 코드를 추가했습니다. 또한 기능에서 pushNotifications를 활성화하고 개발 권한으로 설정된 Entitlement 파일 APN 환경에서도 활성화합니다.응용 프로그램 서버를 통해 연결된 Firebase에서 pushNotifications를 수신 할 수 없습니다.

Firebase 알림 메시지에서 샘플 메시지를 보낼 때 내 iPhone (6)에서 알림을받을 수 있습니다 (FCM 토큰과 함께 bundelId를 통해 알림을받을 수 있음). 하지만 동일한 FCM 토큰을 가진 응용 프로그램 서버에서 알림을받을 수 없지만 firebase에서 200 개의 코드로 알림을 보내면 내 서버 측에서 답장을 보내고 있습니다.

지난 주부터 해결책을 얻지 못하고 모바일 측이나 서버 측에서 문제가 발생하지 않습니다.

미리 감사드립니다 ....

+0

설정이 완료되었습니다.? –

+0

내 콘솔 로그에 으로 표시됩니다. APNS 토큰을 가져 오지 못했습니다. 오류 도메인 = com.firebase.iid Code = 1001 "(null)" – Jeevan

답변

0

문제가 해결되었습니다. 내 위의 코드에서

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
kGCMMessageIDKey = @"gcm.message_id"; 
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { 
    // iOS 7.1 or earlier. Disable the deprecation warnings. 
#pragma clang diagnostic push 
#pragma clang diagnostic ignored "-Wdeprecated-declarations" 
    UIRemoteNotificationType allNotificationTypes = 
    (UIRemoteNotificationTypeSound | 
    UIRemoteNotificationTypeAlert | 
    UIRemoteNotificationTypeBadge); 
    [application registerForRemoteNotificationTypes:allNotificationTypes]; 
#pragma clang diagnostic pop 
} else { 
    // iOS 8 or later 
    // [START register_for_notifications] 
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { 
     UIUserNotificationType allNotificationTypes = 
     (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); 
     UIUserNotificationSettings *settings = 
     [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil]; 
     [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
    } else { 
     // iOS 10 or later 
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 
     // For iOS 10 display notification (sent via APNS) 
     [UNUserNotificationCenter currentNotificationCenter].delegate = self; 
     UNAuthorizationOptions authOptions = 
     UNAuthorizationOptionAlert 
     | UNAuthorizationOptionSound 
     | UNAuthorizationOptionBadge; 
     [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { 
     }]; 

     // For iOS 10 data message (sent via FCM) 
     [FIRMessaging messaging].remoteMessageDelegate = self; 
#endif 
    } 

    [[UIApplication sharedApplication] registerForRemoteNotifications]; 
    // [END register_for_notifications] 
} 

[UIApplication sharedApplication].applicationIconBadgeNumber = 0; 

[FIRApp configure]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:) 
              name:kFIRInstanceIDTokenRefreshNotification object:nil]; 
return YES; 
} 

나는 중포 기지 직접 문서에하지 않은 사실,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:) 
              name:kFIRInstanceIDTokenRefreshNotification object:nil]; 

이 줄

를 작성하지. 또한

그리고이 방법

- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage { 
// Print full message 
NSLog(@"Notification :%@", remoteMessage.appData); 
} 

를 사용하지만 APNS 메이트이기 때문에 통지, 통지 화면에 표시되지 않을 수도 있습니다에 의해 콘솔로 인쇄됩니다 알림을받을 수 있는지 여부를 확인

{"aps":{"alert":"Testing.. (0)","badge":1,"sound":"default"}} 

하지만, 서버 측에서는 다른 형식 일 수 있습니다.