2016-07-08 103 views
2

我是Firebase的新手,我正在尋找一個實施了推送通知的iOS項目,以瞭解Firebase推送通知的工作方式並瞭解它。 有人能告訴我在哪裏可以找到它嗎?ios Firebase推送通知項目

謝謝!

+0

他們有他們的樣品。檢查文檔站點。這不是要求參考項目/庫的地方。 – Shubhank

+0

有關構建iOS應用程序的代碼實驗:https://codelabs.developers.google.com/codelabs/firebase-ios-swift/ –

回答

2

更新:SWIFT 3.0:

如何與火力地堡您的iOS項目整合。

,以便與火力地堡的項目中集成的推送通知,你需要做到以下幾點:

  1. 使用的CocoaPods與火力地堡集成項目。打開終端並編寫cd然後將包含您的項目的文件夾拖到終端,以避免編寫整個路徑。

  2. 一旦你在終端裏面的文件夾,寫上:

    $莢初始化

和新文件會爲您創建一個名爲Podfile

內的項目
  1. 打開Podfile file in您的文本編輯器並在結束關鍵字前添加pod'Firebase'

  2. 保存該文件並返回到終端,並確保您仍在項目路徑中。

  3. 然後在終端中編寫pod install,這應該開始下載Firebase並將其與您的項目集成。

6.一旦完成下載,你應該看到在你的項目文件夾中的新文件與.xcworkspace擴展。這是您現在應該打開的文件。

  1. 轉到下面的鏈接並生成證書,以便將其上傳到控制檯中的Firebase項目。

https://www.mobiloud.com/help/knowledge-base/how-to-export-push-notification-certificate-p12/

  • 打開項目,然後導航到AppDelegate中並執行以下操作;

    //導入您的應用程序的頂部框架

    import Firebase 
    
  • 現在內部應用:didFinishLaunchingWithOptions:方法中添加

    //使用火力地堡庫來配置的API

    FIRApp.configure() 
    
  • 內部registerForRemoteNotifications方法添加以下:

    let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil) 
    
        application.registerUserNotificationSettings(settings) 
    
        application.registerForRemoteNotifications() 
    
  • 更新時間:SWIFT 3.0:

    UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.badge,.sound]) { (granted:Bool, error:Error?) in 
    
          if granted { 
    
          }else{ 
    
          } 
    
         } 
    
    
         UNUserNotificationCenter.current().delegate = self 
    

    和委託:

    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { 
    
    } 
    
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) { 
    
    } 
    
  • 您應該添加以下方法AppDelegate中,以便您在應用程序運行時接收消息;

    func application(application:UIApplication,didReceiveRemoteNotification userInfo: [NSObject : AnyObject],fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { 
    
    print("Message ID: \(userInfo["gcm.message_id"]!)") 
    
    } 
    
  • 按照下面的鏈接,以測試發送推

  • https://firebase.google.com/docs/notifications/ios/console-device

    -1

    有任何SDK,這就是所謂文檔提供的東西。這裏是Firebase documentations的鏈接。按照這一步一步一步解釋。

    此外,您還可以從GitHub的repository消息中找到FCM(雲消息傳遞)的示例項目。

    在這段旅程中,如果你遇到任何困難,那麼在這裏發佈你真正的問題(問題),有人可以引導你通過。