No push notifications on Android via PubNub/Parse - parse-platform

I am stumped here. A Phonegap/Mobile Dev newbie here. Looking for some advice.
I have a phonegap app(with push plugin) developed for both Android and iOS. I was trying to test push notifications on Android. I have the following flow
Device registers with GCM(or APNS) and sends the token back to server.
On Server side I determine the identity of the user and create a channel for them on PubNub.
Server registers the device with PubNub along with the channels.
I can verify that the device has been subscribed to a few channels.
I send a message from server side.
I see it in the PubNub console.
But no notification on Android.
When I try to use one of the free services(found some php code on fiddle) available to try sending messages to the device, it works. I see notifications on the device.
I tried sending messages directly from the PubNub console with no luck.
{
"pn_apns": {
"aps" : {
"alert": "Game update 49ers touchdown",
"badge": 2
},
"teams" : ["49ers", "raiders"],
"score" : [7, 0]
},
"pn_gcm": {
"data" : {
"summary": "Game update 49ers touchdown",
"teams" : ["49ers", "raiders"],
"score" : [7, 0],
"lastplay" : "5yd run up the middle"
}
},
"full_game" : {
"date" : "2014.05.20",
"background" : "Data that is not pertinent to devices"
},"pn_debug": true
}
Note 1 - I have already added the GCM API key on PubNub.
Note 2 - I am using the free tier
So, I figured, maybe something wrong with PubNub and I move to Parse.
I create channels, register device and send messages all via curl(REST). I see push notifications on parse dashboard but still no messages on the device.
I haven't tested on iOS yet(working on some other iOS related issues).
I have followed the tutorials to the line for both PubNub and Parse. At this point, I am wondering if the device themselves need to subscribe to PubNub/Parse and a backend service cannot be used to subscribe them.
Please help.

Related

Xamarin android push notification OnMessageReceived() event is not calling when app is on background or killed mode

I have a xamarin forms application and I implemented push notification on it. I want to navigate to different pages when user taps on the push notification depends on the notification data. So for that doing some codes in OnMessageReceived event and it's working as expected if app is open mode. But this event is not triggering on other modes, please help me on this.
I refer this link to implement push notification ,pushnotification on xamarin forms.
Here is my json payload for android.
{
"notification":
{ "title" : "Sample App", "body" : "New items are available"},
"data" :
{"Id" : "876df123", "pageName" : "ClothingsPage" }
}
At first, there was an existed issue on the github which is about Xamarin.Forms Android Pushnotification FCM OnMessageReceived not fired when app is background. And the comment in it explains the cause.
In addition, there is an open issue about the push notification when app is closed. And you can try the accepted answer in this case which is about the FCM messages unable to be handled when app is killed.
Generally speaking, it seems the cause is the limit of the push notification in the xamarin's android platform. You can check the official document about the firebase message service.
Changed the notification payload to the below format, after that it worked.
{"data" : {"Id" : "123456", "body" : " test mobile app", "title" :  "SampleTest" } }

Notification Hub Help on Xamarin

I have Azure notification hub working on Xamarin Forms for iOS and Droid to receive general push notifications. I am trying to send a POSTID in my payload and then take that ID and direct to the data behind it. My issue, I cannot seem to get the postid to read into the app. Every time I get an empty ID. The Push notification an Droid and are received, but the extra data, like postid are not.
{"aps":{"alert":"Test #03_01","postid":"8921"}}
Can someone point me to some documentation on this? How to make it work with ID/data in the push notification behind the scene.
You'll need to promote your custom data fields. At the moment, they are in the "aps" section, which is reserved for data that will be consumed by APNS or iOS. Somewhere along the line your fields are being stripped.
Here's the APNS documentation for building request payloads.
For you it should look something like:
{
"aps": {
"alert":"Test #03_01"
},
"postid":"8921"
}

Microsoft Teams incorrect conversation information data

I'm working on teams bot project and i've found an issue with the IOS devices.
When IOS user sends a message to our bot we receive correct conversation information data from Microsoft service and we can reply to a client using that information.
We have next flow:
User requests card.
User clicks on the card to open task module window.
When IOS user requests the card we receive a correct conversation information from the service:
"conversation" : {
"group" : true,
"isGroup" : true,
"conversationType" : "channel",
"tenantId" : "5df.....-....-....-....-.........656",
"id" : "19:6ff255c919a34641b7d2fb59df150ebf#thread.skype;messageid=1589553462779"
}
Next we reply to user using that conversation information with the card which contains task module button.
IOS User clicks on that button and we receive incorrect conversation information data from service:
"conversation" : {
"group" : false,
"isGroup" : false,
"tenantId" : "5df.....-....-....-....-.........656",
"id" : "29:16qvJAfN2glqz_YAypLR2db_gjXvdZwtM-Au5-Gnd7y-GgLV0jVR8xyYcT6COQHcvMnjLDE6wQmlNRaUnW-x_iQ"
}
We performed all actions above in the same channel but we received different channel information. Also with that incorrect channel information we can't reply to a user.
As you can see:
"group": false # is incorrect
"isGroup" : false . # is incorrect
"tenantId" : "5df.....-....-....-....-.........656" # is correct, the same value
"id" : "29:16qvJAfN2glqz_YAypLR2db_gjXvdZwtM-Au5-Gnd7y-GgLV0jVR8xyYcT6COQHcvMnjLDE6wQmlNRaUnW-x_iQ" . # is incorrect
looks inconsistent. Other platforms are working fine (android, desktop, browser).
Bot was built on java and we use these libs:
com.microsoft.bot:bot-connector:4.6.0
com.microsoft.bot:bot-integration-core:4.6.0
com.microsoft.bot:bot-schema:4.6.0
com.microsoft.bot:bot-builder:4.6.0
From this source:
https://github.com/microsoft/botbuilder-java
unfortunately this is a bug with task/fetch button actions sent by a bot, in the current version of the iOS Teams app. We have a fix ready, and it will be available with the next release.

Back4App Push notifications are without data

I use Back4App service to send push notifications. I managed to get push notifications to work, and they work from the client and from the server, but the problem is that all notifications come with the same format (title>name of the app, alert>name of the app).
I am sure I am changing the alert and the title text in the json, but still they are all sent with the app name.
This is my json table:
{
"channels": [
"TestChannel"
],
"data": {
"alert": "The Mets scored! The game is now tied 1-1.",
"title": "Mets Score!"
}
}
Here is how I call the function (using lua in corona SDK):
parse.request(parse.Push.send)
:data(pushJson)
:response(function(responseString, responseTable, errorTable)
adjustResponseString("Sending Push", responseString, responseTable, errorTable)
end)
This is my current app name "ParseTest".
Here is what the notification looks like:
https://i.snag.gy/rXQ9Ja.jpg
(This is the case when I send push notifications from both client and server.)
at the moment, I'll recommend to you work with Cloud Code Function (It works with JS SDK) and you can call it via your project app, the guides are:
What is Cloud Code function?
You can send Pushes via your JS SDK using this link.

React To PushNotification Received even if the App is Closed

I know there are a lot of questions related to this subject, but after searching I found out that they all say that if the app is closed then the only way is to fetch the notification again from the server once the app is opened or if the app is opened from the notification then you can handle it in didFinishWithLaunch but using WhatsApp, this is not the case...
I tried sending a message to phone B (which had whatsapp closed), Phone B received the notification. Then I turned off the internet on Phone B and opened the app and still received the chat message.
Can anyone guide me on how to do this?
Probably you should use one of background modes - "remote-notification".
After enabling it, you can send push with payload like
{
"alert": "",
"badge": "0",
"content-available": 1,
"sound": ""
}
if you specify content-available key equal 1, iOS will wake your app and call application:didReceiveRemoteNotification:fetchCompletionHandler: in app delegate and you have some time to proceed push and prepare app (like download this new message to device). Here is Apple docs link with info about push payloads.
However please be aware that this push delivering is not guaranteed. Apple tells
(Newsstand apps are guaranteed to be able to receive at least one push with this key per 24-hour window.)
In our experience you likely receive it most of the time, but not always. For example app delegate callback will not be called if user swiped to close your app.
Also you need to finish execution in 30 seconds or less and call the block in handler parameter (you can check discussion section of method documentation for more details)

Resources