hansemannn / titanium-firebase-cloud-messaging

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

More details on how to register the events. #2

Closed malhajj closed 6 years ago

malhajj commented 7 years ago

We are willing to use this module, we make it work and start receiving notifications, but the issue was that both event listeners are not working or we are using them in a wrong manner due to lack of description

for example, we used the handler like that:

firebaseCloudMessaging.addEventListener("didReceiveMessage", function(e) {console.log(e);});

This handler was never triggered at all, the notification was received but with no handler.

Thanks for this great module, and your help on that is much appreciated

hansemannn commented 7 years ago

Interesting behavior. I just pushed a 1.0.1 prelrelease that could fix this issue, please try it out here.

malhajj commented 6 years ago

Hi @hansemannn ,

We've checked version 1.0.1 and seems it stills not working or we are implementing it in a wrong way unless we followed these steps: 1- install both firebase-core and cloud-messaging developed by you. 2- from firebase console, create project, and enable notification and add the needed development certificate for APNS. 3- implement the below code for testing:

var firebase = require('firebase.cloudmessaging');
require('firebase.core').configure({
    googleAppID: "*:**********:ios:************",
    GCMSenderID: "*************" //Sender ID
});
console.log('deviceId ' + firebase.fcmToken);
firebase.addEventListener('didReceiveMessage', function (e) {
    console.log('didReceiveMessage');
});

The result after pushing notification from FCM notification php script:

  1. Notification received correctly on iPhone 7 and handler is not fired.
  2. Notification is not received on older devices such as iPhone 5 and iPhone 5s (64bit) (device token is updated according to the received one).

Thanks,

fermindelonia commented 6 years ago

Hi @malhajj , @hansemannn

Same problem here.

Wingee commented 6 years ago

Argh, same thing happening for me too. I've tried 1.0.1 and it's not working @hansemannn any ideas?

hansemannn commented 6 years ago

Sorry, no time for OSS support right now.

hansemannn commented 6 years ago

I just checked this again and compared it with the native implementation and docs. appDidReceiveMessage is a method and should only be called manually, if Firebase method swizzling (enabled by default) is disable. If called, it should be done on the application: didReceiveRemoteNotification: delegate.

The didReceiveMessage: delegate is only called if enabled via the FIRMessaging delegate, which is currently not done. Also note that you need to set setShouldEstablishDirectChannel on the module to true in order to receive direct messages. Also note that the event is iOS 10+ only and push notifications are still received via application:didReceiveRemoteNotification: event which is handled via the usual notification events in Titanium.

I've updated the docs to reflect this native behavior.