ios - getting Firebase Cloud messaging running swift -
i following google's instructions on setting firebase https://www.firebase.com/docs/ios/quickstart.html suspect problem may because legacy version. deprecated should not read error, @ least have found apple deprecations. following code:
import uikit import firebase class firstviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() var myrootref = firebase(url:"https://<your-firebase-app>.firebaseio.com") // write data firebase myrootref.setvalue("do have data? you'll love firebase.") // additional setup after loading view, typically nib. }
gives following error
cannot call value of non-function type 'module<firebase>'
from link, exact same code prescribed. have installed pods firebase , firebase cloud messaging.
cannot call value of non-function type 'module'
the error saying imported module named firebase
here:
import uikit import firebase
and tried calling module if it's function:
override func viewdidload() { super.viewdidload() var myrootref = firebase(...)
i think old firebase module must have defined function/class called firebase, when imported old firebase module, made firebase() function/initializer available. apparently, new firebase module doesn't define function/class anymore, hence need new instructions.
in addition, url can't correct:
url:"https://<your-firebase-app>.firebaseio.com"
you substitute actual name of app in place of <your-firebase-app>
.
in case, don't specify url in code anymore: instead call firapp.configure()
in appdelegate.swift, , takes care of connecting proper url you. how configure(
) know url connect to? in googleservice-info.plist file dragged app--you’ll see db url in there.
to reference top of db, is:
dbref = firdatabase.database().reference()
here in viewcontroller:
class viewcontroller: uiviewcontroller { var dbref: firdatabasereference! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. dbref = firdatabase.database().reference() dbref.child("person").child("name").setvalue("joe")
after running app, you'll see following @ firebase website:
abcd-1234 |____person |__name: “joe”
Comments
Post a Comment