Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Notification channel id #29

Open
rayansys opened this issue Aug 1, 2020 · 11 comments
Open

Android Notification channel id #29

rayansys opened this issue Aug 1, 2020 · 11 comments

Comments

@rayansys
Copy link

rayansys commented Aug 1, 2020

add this header & functions

@AndyGaskell
Copy link
Collaborator

Hi @rayansys

Could you provide a bit more info please? Perhaps some detail on what you're trying to do and where you hit this issue.

Fireball cloud messaging doesn't really have channels, but topics instead. Topics are fully supported by php-fcm.

More info...

https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

https://php-fcm.readthedocs.io/en/latest/message.html#notification-message-topics

Sorry if I've misunderstood the issue.

@rayansys
Copy link
Author

rayansys commented Aug 2, 2020

The notification's channel id (new in Android O).

The app must create a channel with this channel ID before any notification with this channel ID is received.

If you don't send this channel ID in the request, or if the channel ID provided has not yet been created by the app, FCM uses the channel ID specified in the app manifest.

@AndyGaskell
Copy link
Collaborator

Thanks for the quick reply.

The php-fcm library just really wraps functionality in provided by firebase cloud messaging. If you can point us to the fcm docs about channels, that'd be handy.

Previously I've used other messaging systems that used the term channels, like Appcelerator ACS. It was my understanding that the concept channels is kind of implemented as topics now in FCM, but I'm not really sure.

@rolinger
Copy link
Collaborator

rolinger commented Aug 2, 2020

@AndyGaskell @rayansys - yeah, I don't understand the request. TopicIDs are managed by php-fcm. Can you point us to some documentation about what you are referring to please?

@rayansys
Copy link
Author

rayansys commented Aug 2, 2020

@AndyGaskell
Copy link
Collaborator

Thanks for the link. I'll do some reading on that. I guess we've not implemented it because it's Android only.

@rolinger
Copy link
Collaborator

rolinger commented Aug 3, 2020

@AndyGaskell - I did a quick read, it looks like channel ID allows you to setup different types of notifications within your app which then allows users to turn off/on specific types of Push Notifications versus just ALL ON or ALL OFF. Which I do like. It allows the user to customize, via Android settings, what components inside each app can notify and how they can notify (sound, buzz, popup, silent in background, etc). I wonder if Apple will do the same soon too?

https://developer.android.com/guide/topics/ui/notifiers/notifications#ManageChannels

@rayansys
Copy link
Author

rayansys commented Aug 3, 2020

just add "android_channel_id" to request header

@AndyGaskell
Copy link
Collaborator

Cool, am understanding it a bit more now. Thanks for the notes @rolinger

I guess we've only ever implemented the cross platform features of FCM, we could do the platform specific ones too.

So, looking at https://firebase.google.com/docs/reference/fcm/rest/v1/projects.message we could add other functions to add android, webpush and apns. This could maybe be done in the same way as the addData, so we'd have $notification->addAndroidConfig($android_config_object);, $notification->addWebpushConfig($webpush_config_object); and $notification->addApnsConfig($apns_config_object); This is a bit like how the FirebasePHP lib does it, see https://firebase-php.readthedocs.io/en/5.7.0/cloud-messaging.html#adding-target-platform-specific-configuration

Another option, which would be much quicker, would be to just add another parameter to the Notification constructor for the channel. Then, I guess, add a setChannel function. If we did it this way it'd just work in the same way as sounds, icon, colour etc. It'd be a bit of a mess if we wanted to add other platform specific options though.
https://github.com/EdwinHoksberg/php-fcm/blob/master/src/Push/Notification.php

One thing I'm a bit worried about is how we'd test all this, at a system level.

Also @rayansys I'm a bit confused about how you mention adding it to the header. From the docs it looks like it goes in the json body.

@AndyGaskell
Copy link
Collaborator

Thanks for the PR @rayansys this is a nice simple aproach, but I'm not sure how it'll scale out to other Android, iOS and Web config options.

PR at...
Update Notification.php #30

@Mike-Benoit
Copy link

Thanks for the PR @rayansys this is a nice simple aproach, but I'm not sure how it'll scale out to other Android, iOS and Web config options.

PR at...
Update Notification.php #30

This functionality would be really nice to have, @AndyGaskell will you only accept a design similar to what you described in your previous comment regarding addAndroidConfig(), addApnsConfig()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants