簡體   English   中英

Firebase存儲在NotificationServiceExtension上配置錯誤

[英]Firebase storage configure error on NotificationServiceExtension

我嘗試在NotificationServiceExtension中使用Firebase存儲。 但是FIRApp.configure()不起作用。 調試在此行停止,但從不跳到下一行。 可能會引發異常。 我嘗試使用單獨的GoogleService-Info.plist(帶有擴展束ID),並且與主應用程序plist相同。 相同的代碼在應用程序中可以正常工作。 我錯過了什么? 如果有人有經驗,請說我對我很好:)。 謝謝。 這是我的代碼:

import Firebase
import FirebaseStorage

final class NotificationService: UNNotificationServiceExtension {

    lazy var onceFIRConfigure: Void  = {
       FIRApp.configure()
       return
    }()

    override internal func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void){

...

       let _ = onceFIRConfigure

       // Sign In to Firebase
...
    }
}

我會嘗試將其包裝在dispatch_once中:

var token: dispatch_once_t = 0
dispatch_once(&token) {
    FIRApp.configure()
}

似乎可以在我的鍵盤擴展中工作( https://github.com/mcdonamp/tasty-imitation-keyboard/commit/2042a6572e3b18320dd4b4a6bb6c93e697903edf

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM