2017-07-03 4 views
2

スワップコードで「permission_denied」を確認するにはどうすればいいですか?ユーザーに適切なアラートを表示することができますか?Firebaseの許可が拒否されているかどうかをチェックする方法は?

self.ref = Database.database().reference(withPath: "PlayerBoxes") 
    // 
    handle = ref.child(pID).observe(.value, with: { snapshot in 
     // Do Something 
    }) { (error) in 
     print(error.localizedDescription) 
    } 



    // Update info into Firebase, do not overwrite entire node 
    ref.child(self.pID).updateChildValues(sqr.toDictionary()) <-- Permission Denied 
+0

あなたの質問とあなたの質問が解決されるため、私の回答は回答として受け入れてください。ハッピーコーディング:) – eshirima

答えて

2

代わりにupdateChildValues(withCompletionBlock:)を使用する必要があります。

これは、発生したエラーと共にデ​​ータベース参照を返します。

ref.child(self.pID).updateChildValues(sqr.toDictionary()) { (error, reference) in 
    if error != nil 
    { 
     // handle the error 
     print(error!.localizedDescription) 
    } 

    // you're fine, no error raised 
} 
関連する問題