hansemannn / titanium-firebase-cloud-messaging

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

Android : FA: Failed to retrieve Firebase Instance ID and Given String Is empty or null #119

Closed argum closed 3 years ago

argum commented 3 years ago

Hello,

First of all I want to thank you all your job.

I am having problems using this module.

I have tested with core.configure(); and without it. Same problem. The google-services.json are located on /platform/android/, but I have also copied on /Resources/android/ and even in /Resources/. I am not setting any option on tiapp.xml to change the manifest. If I add the settings on the manifest that you suggest on the documentation, compiler throws an error : duplicated entry.

I don't know what I am doing wrong.

Thank you for your support!!

Setup SDK 9.2.0 Ti.playservices 17.1.1 Firebase.core 6.0.0 firebase.cloudmessaging 3.0.1 ti.cloudpush 7.1.0 (i also tested 6.0.1 with same results)

I have also remove ti.cloudpush from the modules, but error is the same.

The code:

// Import core module
var core = require('firebase.core');
// Configure core module (required for all Firebase modules).
//core.configure();

// Important: The cloud messaging module has to imported after (!) the configure()
// method of the core module is called
var fcm = require('firebase.cloudmessaging');

// Called when the Firebase token is registered or refreshed.
fcm.addEventListener('didRefreshRegistrationToken', function(e) {
    Ti.API.error('didRefreshRegistrationToken', e.fcmToken);
});

// Called when direct messages arrive. Note that these are different from push notifications.
fcm.addEventListener('didReceiveMessage', function(e) {
    Ti.API.error('didReceiveMessage', e.message);
});

if(utils.IS_IOS){
    iOSRegisterForPushNotifications();
}
else{
    var channel = Ti.Android.NotificationManager.createNotificationChannel({
        id: 'default',
        name: 'Default channel',
        importance: Ti.Android.IMPORTANCE_DEFAULT,
        enableLights: true,
        enableVibration: true,
        showBadge: true
    });
    fcm.notificationChannel = channel;
    // display last data:
    Ti.API.error("Last data: " + fcm.lastData);
}

// Check if token is already available.
if (fcm.fcmToken) {
    Ti.API.error('FCM-Token', fcm.fcmToken);
} else {
    Ti.API.error('Token is empty. Waiting for the token callback ...');
}

// Subscribe to a topic.
fcm.subscribeToTopic(declara.pushTopic);

The response: [WARN] : FA: Failed to retrieve Firebase Instance Id [WARN] : Success login to d2web: {user: , token: b772e5ce6c69e8c6cf7e6355dbf573ea, service: http://d2web-api.iit.idisc.es/wsm/v3/(1)} [ERROR] : Sender ID: 623396497913 [ERROR] : Last data: [object Object] [ERROR] : Token is empty. Waiting for the token callback ...

[WARN] : Params: {"user":"","password":"","id_site":1,"udid":"7afedd83faf2757b"} [WARN] : d2web Auth: false [WARN] : Time waiting response: 0.15700006484985352 [WARN] : Time processing callback: 0.04900002479553223 [WARN] : FirebaseCloudMessaging: (main) [10,1097] getInstanceId failed: [WARN] : FirebaseCloudMessaging: java.lang.IllegalArgumentException: Given String is empty or null [WARN] : FirebaseCloudMessaging: at com.google.android.gms.common.internal.Preconditions.checkNotEmpty(Unknown Source) [WARN] : FirebaseCloudMessaging: at com.google.firebase.installations.FirebaseInstallations.preConditionChecks(com.google.firebase:firebase-installations@@16.2.2:147) [WARN] : FirebaseCloudMessaging: at com.google.firebase.installations.FirebaseInstallations.getId(com.google.firebase:firebase-installations@@16.2.2:207) [WARN] : FirebaseCloudMessaging: at com.google.firebase.iid.FirebaseInstanceId.zzl(com.google.firebase:firebase-iid@@20.1.6:70) [WARN] : FirebaseCloudMessaging: at com.google.firebase.iid.FirebaseInstanceId.zza(com.google.firebase:firebase-iid@@20.1.6:154) [WARN] : FirebaseCloudMessaging: at com.google.firebase.iid.zzk.then(com.google.firebase:firebase-iid@@20.1.6) [WARN] : FirebaseCloudMessaging: at com.google.android.gms.tasks.zzf.run(Unknown Source) [WARN] : FirebaseCloudMessaging: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) [WARN] : FirebaseCloudMessaging: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) [WARN] : FirebaseCloudMessaging: at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source) [WARN] : FirebaseCloudMessaging: at java.lang.Thread.run(Thread.java:761)

m1ga commented 3 years ago

Did you try https://github.com/hansemannn/titanium-firebase#android-notes ? Also: is your google-services.json correct? Does the package_name match, is there a current_key? Which version of the modules are you using and which Ti SDK?

argum commented 3 years ago

Hello m1ga. Thank you for your quick response. I have edited my post and add more data. I just download again google-services.json from firebase console and also.

I will try your suggestion. https://github.com/hansemannn/titanium-firebase#android-notes

Setup SDK 9.2.0 Ti.playservices 17.1.1 Firebase.core 6.0.0 firebase.cloudmessaging 3.0.1 ti.cloudpush 7.1.0 (i also tested 6.0.1 with same results)

m1ga commented 3 years ago

please try https://github.com/appcelerator-modules/ti.playservices/releases/tag/v17.3.0 too

argum commented 3 years ago

Creating XML file works like a charm. Thanks!

I have not test new version of ti play services. But if you want me to test it, I will do.

m1ga commented 3 years ago

Nice! if things work fine then I would stick to it :) When you update to newer firebase modules you can consider updating playservices too