hansemannn / titanium-firebase-cloud-messaging

Use the Firebase Cloud Messaging SDK in Axway Titanium 🚀 Edit
Other
43 stars 31 forks source link

Android crashes because applicationID required #14

Closed ghost closed 6 years ago

ghost commented 6 years ago

I somehow need a placeholder value for the applicationID property in order for Android not to throw an error:

var core = require('firebase.core');
core.configure({
  googleAppID: 'abc-def-ghi',
  GCMSenderID: '123890'
  applicationID: 'PLACEHOLDERVALUE'
});

Error:

[ERROR] TiExceptionHandler: (main) [3977,4239] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [1,4240] - In /push_notifications.js:85,22
[ERROR] TiExceptionHandler: (main) [0,4240] - Message: Uncaught Default FirebaseApp is not initialized in this process com.testapp. Make sure to call FirebaseApp.initializeApp(Context) first.
[ERROR] TiExceptionHandler: (main) [0,4240] - Source:             this.FCM.registerForPushNotifications();
[ERROR] V8Exception: Exception occurred at /push_notifications.js:85: Uncaught Default FirebaseApp is not initialized in this process com.testapp. Make sure to call FirebaseApp.initializeApp(Context) first.
[ERROR] V8Exception: Default FirebaseApp is not initialized in this process com.testapp. Make sure to call FirebaseApp.initializeApp(Context) first.

I am not sure why it is required, but FCM functions without it as I've just put a string placeholder.

Fix suggestion: do not make it required at all.

Feature suggestion: implement google-services.json (Android config file from Firebase) for the file configuration property. That solves any of these issues since you are required to pass the whole config file. I could easily write a parser for javascript, but that cannot go in the module.

m1ga commented 6 years ago

I'm not sure if it is required or not The Google App ID that is used to uniquely identify an instance of an app. but it doesn't list any required values. It is inside the google-services.json which you can put into /app/assets/android

BTW: I think this is more an issue of firebase-core

ghost commented 6 years ago

yea didnt know where to put it, since configure() works fine without it. Only when I call the fcm stuff it errors.

Btw does that work out of the box? Putting in /app/assets/android/google-services.json?

m1ga commented 6 years ago

https://github.com/hansemannn/titanium-firebase#installation

my test setup: screenshot_20180426_192530

I just use configure() with no parameter and it will use the file

ghost commented 6 years ago

oh thats great, i wasnt aware. Since iOS has this file property, i assumed Android didnt support it.

I hadnt even seen the repository you linked. That json-file feature should be put at firebase.core's readme since it's about the configure() method.

The firebase.core readme literally said "configure(): Configure Firebase without additional parameters."

Another confusing thing is that the linked repo does not mention the file property. I would suggest removing as much of the explanation there and put it under firebase.core.

I'll see if i can create a PR but it'll likely be tomorrow

m1ga commented 6 years ago

I'm just implementing the file parameter as we speak :grinning:

m1ga commented 6 years ago

https://github.com/hansemannn/titanium-firebase-core/issues/11