morinel / gcmpush

Titanium Module for Android Push
Apache License 2.0
57 stars 35 forks source link

FCM compatibility #50

Open kaiiserni opened 8 years ago

kaiiserni commented 8 years ago

Would it be easy to add compatibility to the new FCM which Google is pushing now? https://developers.google.com/cloud-messaging/android/android-migrate-fcm

morinel commented 8 years ago

Probably, maybe you could propose an update and send a pull request?

Thanks!

kaiiserni commented 8 years ago

Sure, will try to do that later this month!

On Mon, Aug 29, 2016, 13:41 Jeroen van Vianen notifications@github.com wrote:

Probably, maybe you could propose an update and send a pull request?

Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/morinel/gcmpush/issues/50#issuecomment-243101305, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFXFh8Azj4GyaPUT3meSeZJi9ShYwamks5qksV3gaJpZM4JvYHS .

morinel commented 8 years ago

Thanks, such a change might warrant a 2.0 release.

DaKaZ commented 8 years ago

Any progress on the FCM updates? With google using language like:

GCM users are strongly recommended to upgrade to FCM

I am guessing GCM will be EOL soon

cr0ybot commented 6 years ago

"As of April 10, 2018, Google has deprecated GCM. The GCM server and client APIs are deprecated and will be removed as soon as April 11, 2019."

Looks like we need to get going on this as soon as possible...

cr0ybot commented 6 years ago

After doing some digging, it looks like this will be a non-trivial change to the code. Apparently GCMBaseIntentService and GCMBroadcastReceiver were deprecated long ago, so the switch to Firebase will not be a straight path. The GCM-FCM migration guide is expecting you to be using GcmListenerService.

cr0ybot commented 6 years ago

Just wanted to post an update that I'm close; see my fork (firebase branch) here: https://github.com/cr0ybot/gcmpush/tree/firebase

It's a big change to the code, but it is so far mostly backward compatible with the current module's interface. The setup process is just a bit more involved.

However, I'm still not actually receiving notifications from Firebase... so more to come.

morinel commented 6 years ago

@cr0ybot Thanks very much for your efforts so far.

cr0ybot commented 6 years ago

Seems like the thing I was missing in order to get notification data was setting the SHA1 in the Firebase project settings. I've documented that process in the docs/README, and I think I'm ready to create a pull request.

cr0ybot commented 6 years ago

Seems I was mistaken about needing that SHA1 set, I just removed them from the Firebase console and everything is working fine. I'm going to update the README/docs again and remove that bit.

adegreiff commented 6 years ago

hi @cr0ybot , thanks for your fcm branch. works good. when our app is closed i do not receive push messages, though. from debug i get this:

E NotificationService: No Channel found for pkg=..., channelId=null, id=1, tag=null, opPkg=..., callingUid=10318, userId=0, incomingUserId=0, notificationUid=10318, notification=Notification(channel=null pri=2 contentView=null vibrate=default sound=... defaults=0x6 flags=0x10 color=0x00000000 groupKey=... number=0 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)

in the notificationSettings i have included the new keys channelId and channelName but they seem to be ignored.

can you give me a hint for further debugging?

thanks alexander

cr0ybot commented 6 years ago

@adegreiff Sorry, I did not have an Android O device for testing this. It looks like I didn't do the channelId/channelName stuff properly. The notification building stuff is happening in FCMService::onMessageReceived().

I think that line 502-513 probably need to be moved up before line 437, and after notificationManager.createNotificationChannel(channel); should be a line like: builder.setChannelId(channelId);

Sorry I can't get to updating this right now, but if you get it working I'd be happy to accept a pull request to this pull request!

Stackoverflow reference: https://stackoverflow.com/a/45692202

adegreiff commented 6 years ago

@cr0ybot thanks so much for the hint. this did the trick. i have created a pull request. greetings from germany ;-)

cr0ybot commented 6 years ago

@adegreiff Awesome! I've pulled your contributions into my branch.

fahad86 commented 6 years ago

@adegreiff does the "fcm_fallback_notification_channel_label" attribute work as intended? I've pulled cr0ybot/gcmpush(master) and I still can't get the notifications while the app is closed or in the background. When I open the app I can however see that calling getLastData() returns the data from the push.