2017-09-24 27 views
0

我跟着火力網站上的文檔指南,做了以下所有的東西:火力地堡雲消息(FCM)不工作

實現的代碼AppDelegate.swift。

2.將豆莢添加到我的豆莢文件並安裝。在Certifictes

創建APN認證密鑰,標識符在我developer.apple帳戶& 型材並在FCM設置粘貼。

4.在項目功能中啓用了推送通知(已勾選兩項v)。

5.創建的證書類型:蘋果推送服務生產

我送情侶的通知,從火力控制檯,並在我的iPhone(IOS 10.3)並沒有收到任何。 任何提示要檢查什麼?我錯過了什麼?


Podfile

use_frameworks! 

    # Pods for App 
    pod 'Firebase/Core' 
    pod 'Firebase/Crash' 
    pod 'Firebase/Messaging' 

AppDelegate.swift

import UIKit 
import Firebase 
import UserNotifications 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate { 

var window: UIWindow? 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     // Override point for customization after application launch. 

     // Use Firebase library to configure APIs. 
     FirebaseApp.configure() 

     if #available(iOS 10.0, *) { 
      // For iOS 10 display notification (sent via APNS) 
      UNUserNotificationCenter.current().delegate = self 

      let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] 
      UNUserNotificationCenter.current().requestAuthorization(
       options: authOptions, 
       completionHandler: {_, _ in }) 
     } else { 
      let settings: UIUserNotificationSettings = 
       UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) 
      application.registerUserNotificationSettings(settings) 
     } 

     application.registerForRemoteNotifications() 


     return true 
    } 
+0

也許你可以與蘋果推送服務的開發嘗試,而不是生產,因爲我認爲你在調試模式下測試應用程序,而不是特別版本。 –

+0

其實我發現了生產中的問題。我應該啓用後臺模式遠程通知嗎? – LamaTo

+1

你不需要。我收到未啓用後臺模式遠程通知的推送通知。僅當您需要無聲通知時才使用後臺模式遠程通知。 –

回答

0

必須添加一些方法。

只是this one :)

比較你AppDelegate.swift這是從火力,球員的「官方」樣品(我是這麼認爲的:d)