Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Sending one unique push for iOS and Android #2087

Closed
arimk opened this issue Dec 3, 2017 · 6 comments
Closed

Sending one unique push for iOS and Android #2087

arimk opened this issue Dec 3, 2017 · 6 comments
Labels

Comments

@arimk
Copy link

arimk commented Dec 3, 2017

Expected Behaviour

Everything working

Actual Behaviour

Working only on one platform at a time...

Reproduce Scenario (including but not limited to)

Read underneath

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

All

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

All

Cordova CLI version and cordova platform version

Last

Plugin version

Last

Hi,
It is maybe not an issue but a clarification.
I am using only FCM for everything, last version of the plugin, on an ionic app
Reading the (otherwise very clear) docs, I am wondering something.
In the payload doc : https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md
It is explained that for android, you need to send the following, to be able to get the on(notification) handler working on android :
{ "data" : { "title": "Test Notification", "body": "This offer expires at 11:30 or whatever", "notId": 10, "surveyID": "ewtawgreg-gragrag-rgarhthgbad" } }
and it is also written to never use the "notification" part in the payload, if you actually want the handler to work.
Now this is clear and it is working on Android.

But on iOS, it also clearly written to do exactly the opposite :
{ "registration_ids": ["my device id"], "notification": { "title": "My Title", "body": "My message" } "data": { "key1": "data 1", "key2": "data 2" } }

So the big issue here is, the whole idea of using FCM is not having to handle (on a high level) the differences between iOS and Android.
Now I understand that it is totally the opposite that is needed. You have to know exactly which type of device is your user using (as the registration callback does not give it, you have to do it on your own).
That also means that if you want to send a notification to a FCM group (like "all users") you have to do it twice, one for all Android users, one for all iOS users.

Am I missing something?
Shouldn't it be explained in the documentation somewhere?
There is no way to make an FCM notification working for both environnement at once?

Thanks, no sure if it is the right place but it seems extremely strange from a user perspective.

@macdonst macdonst added the docs label Dec 4, 2017
@macdonst
Copy link
Member

macdonst commented Dec 4, 2017

@arimk No, you are not missing something. If you read:

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#notification-vs-data-payloads

You should get an overview of why the plugin requires everything in the data section instead of notification. That's just a limitation of the way pushes are handled on Android and the need to pass along the event to the JS layer.

With iOS we are using FCM libs directly from Google which require the push in notification.

I really wish I could make this consistent but I can't.

@arimk
Copy link
Author

arimk commented Dec 4, 2017

Thnaks @macdonst
Alright, so I really need to add the device type on subscription and send the correct notification, and handle twice in my app :(
I really think it should be written as is from the begining of the documentation as most of the people use cordova/ionic/phonegap to build multi platforms apps so it can be clear. But when you read in details it is indeed explained.

I still don't really get why when you have data and notification at the same time, the on('notification') handler is not called. It should be.

Thanks !

@arimk arimk closed this as completed Dec 4, 2017
@macdonst
Copy link
Member

macdonst commented Dec 4, 2017

@arimk it should be but in testing various version of Android/Play Services I haven't found it to be 100% consistent. As well if you put anything in notification then the OS takes over control of the look of the push so options like, icons, sound, action buttons, etc. will not be handled by this plugin.

Your suggestion of having this front and centre in the readme is a good one. I'm going to re-open this issue until I get a chance to add it to the docs. Thanks for the feedback.

@macdonst
Copy link
Member

macdonst commented Dec 5, 2017

@arimk can you give the README a quick look over and see if this makes sense?

@arimk
Copy link
Author

arimk commented Dec 5, 2017

@macdonst It does! Maybe just adding something about having to retreive platform information by yourself as it is not the plugin's role to do it?

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants