parse.com action-loc-key push notifications - ios

I've been trying to find an answer to this all over but I just can't. I know that to change the title of the button on the push notifications on iOS 8 from "View" to something else, I have to specify it in action-loc-key, but how would I do this specifically with Parse.com? Would I create a NSDictionary for alert and make it a key under there and then add that NSDictionary to the JSON payload for the push data or would I add it directly to the push data? Can someone give me an example? T

You can directly set the aps dictionary of the data field of the Parse push payload and set the action-loc-keys exactly as described by Apple.
var payload =
"data":{
"aps":{
"alert":{
"loc-key":"msg",
"loc-args":["John"],
"action-loc-key":"rsp"
},
}
};
// set at least the 'where' key of the payload
Parse.Push.send(payload);

Related

iOS 10 How to set UNotificationContent threadIdentifier for remote notification

TL;DR: What key needs to be set in the APNs notification payload JSON to correspond to the threadIdentifier property of the UNNotificationContent object? e.g. the "category" key corresponds to the categoryIdentifier property.
iOS 10 introduces the Notification Content Extension allowing us to present a view controller when a notification is expanded.
The view controller that we provide conforms to the UNNotificationContentExtension protocol, that requires us to implement the didReceive(_:) method.
The documentation for this method includes the following paragraph:
This method may be called multiple times while your view controller is visible. Specifically, it is called again when a new notification arrives whose threadIdentifier value matches the thread identifier of the notification already being displayed.
The threadIdentifier property may be set in code for local notifications, but I don't know how to set it for remote notifications that are sent from the server to APNs.
The UNNotificationContent documentation describes the property here: http://developer.apple.com/reference/usernotifications/unnotificationcontent
The following JSON includes the keys I've tried ("thread" and "thread-identifier"):
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread" : "example-thread",
"thread-identifier" : "example-thread-identifier"
}
"custom-field" : "some value",
}
I can't find any documentation from Apple about how to set this. Can anyone help?
I discovered from a contact at Apple that the correct key to populate this property is the "thread-id" key.
So the JSON sent to APNs is as follows:
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread-id" : "my conversation blah blah"
}
"custom-field" : "some value",
}
This populates the threadIdentifier property of the UNNotificationContent object accessible in your Notification Content Extension via notification.request.content.threadIdentifier.
By setting this "thread-id" value, it means that the didReceive(_:) method of your content extension will be multiple times. First when expanding the notification initially, and again whenever a new notification arrives with the same "thread-id" value.
I assume (hope) this will be added to the official documentation once iOS 10 is officially released.

Send push notifications to iOS with Amazon SNS and handle them with Localized Formatted Strings

I'm trying to send iOS push notifications from Amazon SNS and i'm able to do it, but i want to use localized formatted string to send the notification and push the message in the right language.
I'm using XCode 7.0.1 and developing with an iPhone 5S, but i think that's not the point.
So this is the message i'm trying to send:
{
"default":"This is the default Message",
"APNS_SANDBOX":"{ "aps" : { "alert" : {
"loc-key" : "GAME_PLAY_REQUEST_FORMAT",
"loc-args" : [ "Jenna", "Frank"]
},"data": { "type": "dashboard", "opponentName":"Juan ","gameCategory":"Multimedia","gameType":"combo","ugid":"123456789" }, "badge" : 9,"sound" :"default"}}"
}
It can be send, but its not changed in the device and the message is "GAME_PLAY_REQUEST_FORMAT", so what i want to be displayed is the value of this key in my Localizable.strings file:
"GAME_PLAY_REQUEST_FORMAT" = "%# and %# have invited you to play";
I've red that you can do it in the apple's documentation (https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW21)
Hope anyone can help.
Thanks
I'll post the answer here so everyone can see it.
#TĂ Truhoada yes, you need to use loc-keys in the payload. You can see how it works in the following link: Creating the Remote Notification Payload
Use loc-key to pass a key that is defined in your application's Localizable.strings file. The iPhone looks up the key and replaces it with the string found for the current localization.
You can see more information in this link from Erica Sadun: Building Notification Payloads

iOS push notification not received when screen is locked

I am using parse for push notification. Once I receive remote notification I pass it to the local notification, but issue is when screen is locked didReceiveRemoteNotification does not hit. I don't receive any notification.
I am using iOS8
Here's my payload:
{
CommentId = "8082a532-2380-4af5-bb3f-d247cfca519b";
CommentTitle = test; action = "com.lelafe.one4communities.Notifications.NotificationActivity";
aps = { };
moduleIdentifier = 8;
nTitle = "Comment posted by someone";
postingID = "c57a3d27-cfe5-41e9-a311-98a9fd7749ad";
}
There is one more parameter that you need to pass to your payload i.e. content-available and set its value to 1. It needs to be passed in case we wish that our app should receive notifications in the background.
The official documentation of parse describes this parameter as follows:
+content-available: (iOS only) If you are a writing a Newsstand app, or an app using the Remote Notification Background Mode introduced in iOS7 (a.k.a. "Background Push"), set this value to 1 to trigger a background download.
The problem is your dictionary aps:
Try checking out Apple's Documentation about The Notification Payload
Also Quoting #mamills answer:
If there is no badge, no alert, and no sound specified in the
dictionary (for the "aps" key) then a default message will not appear
and it will be completely silent.
Look again at example 5 in the document you referenced. aps can be
empty, and you can specify whatever custom data you would like as they
do with the "acme2" key. The "acme2" data is an example of where your
server's "special" payload could reside within the JSON payload.

Trigger.io and Parse channel push notification additional data for deep-linking

I know there is event listener in TriggerIo to catch received push notifications from Parse:
forge.event.messagePushed.addListener(function (msg) {
alert(msg.alert);
});
But the 'msg' object contains only 'alert' and 'sound' keys...
Is there a way to receive at least a channel name to which push notification was sent? I need this to decide which view to open in my app as each channel has it's own destination. And if this is not possible, maybe there is another way to do this?
P.S I suppose it could be done by inserting some kind of 'keyword' into message it self, but I would rather avoid it.
I just realised, that there is a way to send so called JSON payload via Parse push submission form.
{
"alert" : "My message",
"additional" : "data"
}
More info: https://parse.com/questions/json-format-to-send-notification-from-parse

Can I push a Newsstand notification with apn_on_rails?

Is there any way using apn_on_rails to push Newsstand notification? i.e. Push this kind of payload:
{"aps": {"badge": 1,"content-available":"1"} }
At the moment I can see that I can push notification with badge, sound, and alerts.
I'm sure it wouldn't be hard to modify apn_on_rails itself if it turns out it doesn't do it yet. There are so many branches of apn_on_rails, I am using this one at the moment.
The APN::Notification class has a custom_properties property that you use to include any generic data in the push notification. Using your payload as an example, you would do something like this:
apn = APN::Notification.new
apn.badge = 1
apn.custom_properties = {"content-available" => 1}
Grocer also supports Newsstand notifications. https://github.com/grocer/grocer#newsstand-notifications
notification = Grocer::NewsstandNotification.new(device_token: "...")
# Generates a JSON payload like:
# {"aps": {"content-available": 1}}

Resources