Back4App Push notifications are without data - parse-platform

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.

Related

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"
}

Parse.com push notification for web clients by making changes in installation class

I am trying to send push notifications to my web application.
Is there any way to send push notification to my web users using parse.com's push service if i have the GCM_SENDER_ID and my APP_ID ?
Right now the procedure that i am thinking of using is this :
1). Run a service worker on my chrome client which gives me registration id of user . I save this in my installation class in deviceToken field . I also save my gcm_sender_id along with it.
2). Use parse.com's push sending api.
Will this work or do i need to directly make rest calls to https://android.googleapis.com/gcm/send to send my message.

Send push notifications using Registration ID through Azure Notification Hubs

I am trying to use Azure Notification Hubs to send push notifications to a client. I read this article which uses tags to identify each user.
https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-aspnet-backend-windows-dotnet-notify-users/
It does the work, but the number of tags is limited. I was thinking to store and use the Registration ID that the Hub returns.
Is there any way to send notifications using this ID?
Another way would be using the Channel.URI that is returned by WNS. Can this be implemented somehow?
Actually NH limits only number of tags per single registration but per hub you may have as many registrations as you need and each registration may have unique tag which you can use to route the notifications.
Also there is new Installation API for Notification Hubs which I believe fits better for you. It is still not well-documented but well-done and ready to use. Here you can find short description of how to use that API. Readme is about Java but .NET SDK has pretty much the same capabilities (in the end both call same REST API).
Keyword is TAG ! If you use any spesific tag for any registered device which is Android,IOS,Windows OS etc, you can send notification to any specific device.
To do these, you should follow below steps one by one ;
As Client side, register device using a spesific tag to selected Azure Notification Hub
Client Example for Android :
`/*you don't have to use Firebase infrastructure.
You may use other ways. It doesn't matter.*/`
String FCM_token = FirebaseInstanceId.getInstance().getToken();
NotificationHub hub = new NotificationHub(NotificationSettings.HubName,
NotificationSettings.HubListenConnectionString, context);
String registrationID = hub.register(FCM_token, "UniqueTagForThisDevice").getRegistrationId();
Like you see, we have used a unique tag call "UniqueTagForThisDevice" for selected Android device.
As Server Side, you should send notification using that TAG call "UniqueTagForThisDevice".
Server Example using Web API to send push selected Android device :
[HttpGet]
[Route("api/sendnotification/{deviceTag}")]
public async Task<IHttpActionResult> sendNotification(string deviceTag)
{
//deviceTag must be "UniqueTagForThisDevice" !!!
NotificationHubClient Hub = NotificationHubClient.CreateClientFromConnectionString("<DefaultFullSharedAccessSignature>");
var notif = "{ \"data\" : {\"message\":\"Hello Push\"}}";
NotificationOutcome outcome = await Notifications.Instance.Hub.SendGcmNativeNotificationAsync(notif,deviceTag);
if (outcome != null)
{
if (!((outcome.State == NotificationOutcomeState.Abandoned) ||
(outcome.State == NotificationOutcomeState.Unknown)))
{
return Ok("Push sent successfully.");
}
}
//Push sending is failed.
return InternalServerError();
}
As last, you should call above Web API Service method using "UniqueTagForThisDevice" tag from any helper platform (Postman, Fiddler or anothers.).
Note : TAG doesn't have to be deviceToken or similar things. It just have to spesific for each devices. But I suggest you that, if you use WebAPI and it is related with Owin midlleware, you may prefer username as unique tag. I think, this is more available for application scenarios. In this way, you can carry sending notifications from unique devices to unique users ;)
That's all.

Sinch APN shouldSendPushNotifications never called

I can´t make Apple Push Notifications work in development mode. The shouldSendPushNotifications method is never called on the source device when the target device is in background mode. I have uploaded my APN development certificate in the Sinch Dashboard and instant messaging works if both devices are in foreground mode. I have a valid device token which I´m using for my own Push Messages. Here is my code:
sinCli = Sinch.clientWithApplicationKey("XXXX", applicationSecret: "XXXX", environmentHost: "sandbox.sinch.com", userId: sinchUserId)
sinCli.delegate = self
sinCli.setSupportMessaging(true)
if let deviceToken = defaults.dataForKey(Globals.KEY_APN_DEVICE_TOKEN)
{
sinCli.setSupportPushNotifications(true)
sinCli.registerPushNotificationDeviceToken(deviceToken, type: SINPushTypeRemote, apsEnvironment: SINAPSEnvironment.Development)
sinCli.setPushNotificationDisplayName("MyApp")
}
sinCli.start()
sinCli.startListeningOnActiveConnection()
sinCli.messageClient().delegate = self
did I forget something?
I think I need to see your swift wrapper, but it almost looks like you are setting up the client for push (not managed), and then registring the token for managed push.
When using managed push (when you upload to cert to us) shouldSendPush is never called, because Sinch takes care of the pushing, you should just get a push. What you do need is to have a push delegate https://www.sinch.com/tutorials/ios-managed-push/

No push notifications on Android via PubNub/Parse

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.

Resources