2016-06-25 3 views
2

내 휴대 전화에서 원격 푸시 알림을 수신하려고합니다. 휴대 전화를 내 컴퓨터에 연결하고 시뮬레이터를 휴대 전화로 실행하면 Firebase 콘솔에서 보낸 알림이 정상적으로 작동합니다. 그러나, 내가 Testflight에 그것을 업로드하고 내 전화에 다운로드, 내 푸시 알림을 통해오고되지 않습니다.Firebase 푸시 알림이 전화기에서 작동하지 않지만 시뮬레이터에서 작동합니다.

내 인증서가 올바르게 업로드하고 아래에있는 내 코드는

class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 

    override init() { 
     FIRApp.configure() 
     FIRDatabase.database().persistenceEnabled = true 
    } 

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
     // Override point for customization after application launch. 
     let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound] 
     let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 
     application.registerForRemoteNotifications() 
     application.registerUserNotificationSettings(notificationSettings) 

     return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 
    } 

    func application(application: UIApplication, 
     openURL url: NSURL, 
     sourceApplication: String?, 
     annotation: AnyObject) -> Bool { 
      return FBSDKApplicationDelegate.sharedInstance().application(
       application, 
       openURL: url, 
       sourceApplication: sourceApplication, 
       annotation: annotation) 
    } 

    func applicationDidBecomeActive(application: UIApplication) { 
     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
     FBSDKAppEvents.activateApp() 
    } 

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], 
        fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { 
     // If you are receiving a notification message while your app is in the background, 
     // this callback will not be fired till the user taps on the notification launching the application. 
     // TODO: Handle data of notification 

     // Print message ID. 
     print("Message ID: \(userInfo["gcm.message_id"]!)") 

     // Print full message. 
     print("%@", userInfo) 

     completionHandler(.NoData) 
    } 


    func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { 
     print(error) 
     print(error.description) 
    } 
} 

enter image description here

+0

프로덕션 인증서로 푸시 알림을 테스트 할 수 있습니까? 나는 같은 문제가있다. Ad-hoc 빌드는 firebase로부터 푸시 알림을받지 않습니다. – sleepwalkerfx

+0

btw, 스크린 샷에는 개발 인증서 만 표시됩니다. 프로덕션 SSL 인증서를 만들었습니까? – sleepwalkerfx

답변

1

당신은 CERT는있는 APN 배포를 만들고 중포 기지 콘솔에 제출 했입니까?

이 가이드를 확인하십시오. 당신이 당신의 응용 프로그램을 출시 할 준비가되면 https://firebase.google.com/docs/cloud-messaging/ios/certs#configure_an_app_id_for_push_notifications

"이 앱은 이제 푸시 알림 개발 환경을 사용하도록 설정되어, 당신은 푸시 알림을 사용하도록 응용 프로그램을 활성화해야 프로덕션 환경 :이 단계를 반복하되 SSL 인증서 개발 대신 프로덕션 SSL 인증서 섹션에서 인증서 만들기를 클릭합니다. setAPNSToken을 호출하는 경우 형식 값이 올바르게 설정되어 있는지 확인하십시오. 샌드 박스 환경의 경우 FIRInstanceIDAPNSTokenTypeSandbox 또는 다음과 같은 경우 FIRInstanceIDAPNSTokenTypeProd입니다. 생산 환경. 올바른 유형을 설정하지 않으면 메시지가 del이되지 않습니다. 앱에 전송되었습니다. "

+0

나는 그것을 가지고 있다고 믿는다 : - 이미지를 담기 위해 원래의 포스트를 편집했다. – Tim

0

업데이트가 있습니까?

다른 포럼에서이 해결책을 찾았습니다. 당신이 중포 기지를 사용하는 경우, 당신은 추가 할 필요가있는 :

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
[[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox]; 
} 

생산 : FirebaseAppDelegateProxyEnabled: YES

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
[[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeProd]; 
} 

... 이론적으로

TestFlight FirebaseAppDelegateProxyEnabled: NO으로 이럴 필요는 없습니다 ..

관련 문제