Firebase ios unable to get timestamp [Firebase/Database][I-RDB038012] Listener at /serverTimestamp failed:...











up vote
0
down vote

favorite












I'm using this code



var currentTimeStamp: TimeInterval?

let ref = Database.database().reference().child("serverTimestamp")

ref.setValue(ServerValue.timestamp())

ref.observe(.value, with: { snap in

if let t = snap.value as? Timestamp {
// print(t/1000)
// currentTimeStamp = t/1000

//Add additional data(Timestamp) to list
mutableData["timestamp"] = currentTimeStamp

//FINALLY , set data
newdoc.setData(mutableData) { (error) in
completion(docID)
}
}
})


got this error



Firebase/Database][I-RDB038012] Listener at /serverTimestamp failed: permission_denied


my rules set to Auth , but auth user still cant get the time stamp



// These rules grant access to a node matching the authenticated
// user's ID from the Firebase auth token
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}


I want to write the timestamp inside Firebase Realtime Database current structure is .



myproject [null]
|____ serverTimestamp : 1



Thought I have set the rules to complete public still cant get the timestamp










share|improve this question




























    up vote
    0
    down vote

    favorite












    I'm using this code



    var currentTimeStamp: TimeInterval?

    let ref = Database.database().reference().child("serverTimestamp")

    ref.setValue(ServerValue.timestamp())

    ref.observe(.value, with: { snap in

    if let t = snap.value as? Timestamp {
    // print(t/1000)
    // currentTimeStamp = t/1000

    //Add additional data(Timestamp) to list
    mutableData["timestamp"] = currentTimeStamp

    //FINALLY , set data
    newdoc.setData(mutableData) { (error) in
    completion(docID)
    }
    }
    })


    got this error



    Firebase/Database][I-RDB038012] Listener at /serverTimestamp failed: permission_denied


    my rules set to Auth , but auth user still cant get the time stamp



    // These rules grant access to a node matching the authenticated
    // user's ID from the Firebase auth token
    {
    "rules": {
    "users": {
    "$uid": {
    ".read": "$uid === auth.uid",
    ".write": "$uid === auth.uid"
    }
    }
    }
    }


    I want to write the timestamp inside Firebase Realtime Database current structure is .



    myproject [null]
    |____ serverTimestamp : 1



    Thought I have set the rules to complete public still cant get the timestamp










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm using this code



      var currentTimeStamp: TimeInterval?

      let ref = Database.database().reference().child("serverTimestamp")

      ref.setValue(ServerValue.timestamp())

      ref.observe(.value, with: { snap in

      if let t = snap.value as? Timestamp {
      // print(t/1000)
      // currentTimeStamp = t/1000

      //Add additional data(Timestamp) to list
      mutableData["timestamp"] = currentTimeStamp

      //FINALLY , set data
      newdoc.setData(mutableData) { (error) in
      completion(docID)
      }
      }
      })


      got this error



      Firebase/Database][I-RDB038012] Listener at /serverTimestamp failed: permission_denied


      my rules set to Auth , but auth user still cant get the time stamp



      // These rules grant access to a node matching the authenticated
      // user's ID from the Firebase auth token
      {
      "rules": {
      "users": {
      "$uid": {
      ".read": "$uid === auth.uid",
      ".write": "$uid === auth.uid"
      }
      }
      }
      }


      I want to write the timestamp inside Firebase Realtime Database current structure is .



      myproject [null]
      |____ serverTimestamp : 1



      Thought I have set the rules to complete public still cant get the timestamp










      share|improve this question















      I'm using this code



      var currentTimeStamp: TimeInterval?

      let ref = Database.database().reference().child("serverTimestamp")

      ref.setValue(ServerValue.timestamp())

      ref.observe(.value, with: { snap in

      if let t = snap.value as? Timestamp {
      // print(t/1000)
      // currentTimeStamp = t/1000

      //Add additional data(Timestamp) to list
      mutableData["timestamp"] = currentTimeStamp

      //FINALLY , set data
      newdoc.setData(mutableData) { (error) in
      completion(docID)
      }
      }
      })


      got this error



      Firebase/Database][I-RDB038012] Listener at /serverTimestamp failed: permission_denied


      my rules set to Auth , but auth user still cant get the time stamp



      // These rules grant access to a node matching the authenticated
      // user's ID from the Firebase auth token
      {
      "rules": {
      "users": {
      "$uid": {
      ".read": "$uid === auth.uid",
      ".write": "$uid === auth.uid"
      }
      }
      }
      }


      I want to write the timestamp inside Firebase Realtime Database current structure is .



      myproject [null]
      |____ serverTimestamp : 1



      Thought I have set the rules to complete public still cant get the timestamp







      ios swift firebase firebase-realtime-database






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 8:26









      KENdi

      5,6492821




      5,6492821










      asked Nov 9 at 3:38









      Nekkoko Nabby

      51




      51
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Your rules are set for the users node. You need to also specify rules for the "serverTimestamp" node.



              {
          "rules": {
          "users": {
          "$uid": {
          ".read": "$uid === auth.uid",
          ".write": "$uid === auth.uid"
          }
          },
          "serverTimestamp": {
          ".read": "auth_uid != null",
          ".write": "auth_uid != null"
          }
          }
          }


          This is if you keep the structure the same.



          When you specify rules in Firebase the term they use is atomic, you need to specify rules for each node and each sub node applies rules of the parent before applying their own. Your rules are only for the "$uid" node, you didn't specify any rules for "serverTimestamp" and since "serverTimestamp" doesn't fall under "$uid" permission is denied.



          For example with your current permissions if you tried to read/write "users" node you will also get a permission denied. You can only access "users/($uid)/"






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219510%2ffirebase-ios-unable-to-get-timestamp-firebase-databasei-rdb038012-listener-a%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            Your rules are set for the users node. You need to also specify rules for the "serverTimestamp" node.



                {
            "rules": {
            "users": {
            "$uid": {
            ".read": "$uid === auth.uid",
            ".write": "$uid === auth.uid"
            }
            },
            "serverTimestamp": {
            ".read": "auth_uid != null",
            ".write": "auth_uid != null"
            }
            }
            }


            This is if you keep the structure the same.



            When you specify rules in Firebase the term they use is atomic, you need to specify rules for each node and each sub node applies rules of the parent before applying their own. Your rules are only for the "$uid" node, you didn't specify any rules for "serverTimestamp" and since "serverTimestamp" doesn't fall under "$uid" permission is denied.



            For example with your current permissions if you tried to read/write "users" node you will also get a permission denied. You can only access "users/($uid)/"






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              Your rules are set for the users node. You need to also specify rules for the "serverTimestamp" node.



                  {
              "rules": {
              "users": {
              "$uid": {
              ".read": "$uid === auth.uid",
              ".write": "$uid === auth.uid"
              }
              },
              "serverTimestamp": {
              ".read": "auth_uid != null",
              ".write": "auth_uid != null"
              }
              }
              }


              This is if you keep the structure the same.



              When you specify rules in Firebase the term they use is atomic, you need to specify rules for each node and each sub node applies rules of the parent before applying their own. Your rules are only for the "$uid" node, you didn't specify any rules for "serverTimestamp" and since "serverTimestamp" doesn't fall under "$uid" permission is denied.



              For example with your current permissions if you tried to read/write "users" node you will also get a permission denied. You can only access "users/($uid)/"






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                Your rules are set for the users node. You need to also specify rules for the "serverTimestamp" node.



                    {
                "rules": {
                "users": {
                "$uid": {
                ".read": "$uid === auth.uid",
                ".write": "$uid === auth.uid"
                }
                },
                "serverTimestamp": {
                ".read": "auth_uid != null",
                ".write": "auth_uid != null"
                }
                }
                }


                This is if you keep the structure the same.



                When you specify rules in Firebase the term they use is atomic, you need to specify rules for each node and each sub node applies rules of the parent before applying their own. Your rules are only for the "$uid" node, you didn't specify any rules for "serverTimestamp" and since "serverTimestamp" doesn't fall under "$uid" permission is denied.



                For example with your current permissions if you tried to read/write "users" node you will also get a permission denied. You can only access "users/($uid)/"






                share|improve this answer












                Your rules are set for the users node. You need to also specify rules for the "serverTimestamp" node.



                    {
                "rules": {
                "users": {
                "$uid": {
                ".read": "$uid === auth.uid",
                ".write": "$uid === auth.uid"
                }
                },
                "serverTimestamp": {
                ".read": "auth_uid != null",
                ".write": "auth_uid != null"
                }
                }
                }


                This is if you keep the structure the same.



                When you specify rules in Firebase the term they use is atomic, you need to specify rules for each node and each sub node applies rules of the parent before applying their own. Your rules are only for the "$uid" node, you didn't specify any rules for "serverTimestamp" and since "serverTimestamp" doesn't fall under "$uid" permission is denied.



                For example with your current permissions if you tried to read/write "users" node you will also get a permission denied. You can only access "users/($uid)/"







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 6:35









                Alexander

                13619




                13619






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219510%2ffirebase-ios-unable-to-get-timestamp-firebase-databasei-rdb038012-listener-a%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Guess what letter conforming each word

                    Port of Spain

                    Run scheduled task as local user group (not BUILTIN)