Closed geniuscd closed 6 years ago
It seems to exist for GCM(Android) and for Apple watch.
For APNS, the alert would have to be changed from a string to a dictionary
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html https://developers.google.com/cloud-messaging/http-server-ref
alright, so you mean we have to edit the core plugin code and have another updated version (PR request?), or we can have a simple workaround? #192 ?
https://github.com/uniqush/uniqush-push/blob/master/srv/apns/push_service_test.go#L301-L313
A PR for srv/apns/payload.go (and probably GCM) would work.
Manually passing in JSON with the desired title, etc. for uniqush.payload.apns would also work as a workaround.
ok great. I never wrote any go script before, I don't know how to compile it either :p I will try to contribute as much as I can. but please can you give us a curl example of the uniqush.payload.apns? coz I tried to write myself, and it didn't work, or at least I didn't knew how to write it.
Example of how to send a push with uniqush.payload.apns
. Note that you may need to url encode if the url is built manually.
curl http://127.0.0.1:9898 -d service=myservicename -d subscriber=1234 -d uniqush.payload.apns='{"aps":{"alert":{"body":"message body","title":"message title"}}}'
With this example, on an iphone, the title "message title" shows up in bold, below the app name and above the message body.
The previewpush endpoint may also help you. If you provide any additional parameters, it will show you the JSON generated from those parameters
curl http://127.0.0.1:9898/previewpush -d pushservicetype=apns -d pushtype=message -d msg='message body'
{"code":"UNIQUSH_SUCCESS","payload":{"aps":{"alert":{"body":"message body"}},"pushtype":"message"}}
curl http://127.0.0.1:9898/previewpush -d pushservicetype=apns -d pushtype=message -d msg='message body' -d img=myimg
{"code":"UNIQUSH_SUCCESS","payload":{"aps":{"alert":{"body":"message body","launch-image":"myimg"}},"pushtype":"message"}}
curl http://127.0.0.1:9898/previewpush -d pushservicetype=apns -d pushtype=message -d uniqush.payload.apns='{"aps":{"alert":{"body":"message body","title":"message title"}}}'
{"code":"UNIQUSH_SUCCESS","payload":{"aps":{"alert":{"body":"message body","title":"message title"}}}}
ok so the uniqush.payload.apns approach will not work according to this line of code
in order to support the title we should add only two lines of code after this line
case "title": alert["title"]= v
according to apple documentation
Things that I should do later:
The following describes how to push a message to a subscriber.
Can we add a title? I know that push notification payload can also have a title, but it isn't listed here. am I missing something?