I implement the functionality of push Notification in my app. This display text message in push notification but emoji not display. It display ascii code like '\u270c' instead of emoji.
can anyone tell me how to display emoji in push notification
To display Emoji in Push Notification use JSON Decoding at server side. It solves this issue for me
Do this at server side in APNS push notification code and will work like charm
$payload['aps'] = array('alert' => json_decode('"'.$pushMsg['message'].'"'), 'badge' => 0, 'sound' => 'default', 'passcode' => $pushMsg);
You need to change your unicode format to display emoji in push notification and local notification.
Update your unicode as follows:
"\u{270c}"
I hope this will help you.
Reference: https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html
Related
When notification received on IOS device at that time the badge should be changed and Badge should be set before opening the app.
I check this onNotificationOpen() method. But when I tap on notification then it calls.
I use cordova-plugin-firebase.
Here is the link https://github.com/arnesson/cordova-plugin-firebase
But is there a method that calls when the notification received on IOS device?
$ionicPlatform.ready(function() {
if (typeof FirebasePlugin != 'undefined') {
window.FirebasePlugin.subscribe("notficationsubscribe");
// Below method calls when i tap on notifcation and sets the badge number
window.FirebasePlugin.onNotificationOpen(function(data) {
window.FirebasePlugin.setBadgeNumber(4);
}
}
}
Above FirebasePlugin.onNotificationOpen() method calls when I tap on notification and sets the badge number, but I want to set the badge when notification received.
Anyone have ideas? How can I achieve it?
Actually i set a logic for it.
1) I stored a badgeCounter value to database.
2) when i wants to send the notification at that time i retrieve it from database
var badge = badgeCounter // it is an integer value
var notification = {
'title': 'Stock available',
'body': 'Click here to more details...',
'sound': 'default',
'badge': badge
};
3) After tap or click on notification, i cleared the badge using below.
window.FirebasePlugin.setBadgeNumber(0);
4) And also in database i update the value to '0' (zero).
Thus, i solve it and it perfectly works for me.
You don't set this with code, it will set itself based on what your notification contains. You'll have to include "badge":1 (or whatever number) in the notification payload when you send it from your server (Firebase). I'm not sure how it works with firebase, but take a look at the documentation for remote notifications. Notice the "Badge"-key.
Please let me ask about Push Notification issue here.
Our server sent out the data in JSON format like this
{
"notification":
{
"body”:”Test Push Notification (42)”,
"node":"1233837”,
"content-available":"1"
},
"priority":"high"
}
The process of sending out push notification to our app is
We sent out notification from our sever to GCM
From GCM, sending out to APNS.
But when we receive push notification in our app, the format is totally changed (as shown in attached image).
If you face with this kinda issue before, could you share with how to solve it, please?
Or is there any way to change in GCM to get normal JSON format?
Try next format to send notification to GCM:
{ "notification": { "body”:”Test Push Notification (42)”, "node":"1233837” }, "priority":10, "content-available":true }
From APNS you app get some like this
{
aps:{
alert:{
*bla bla bla*
},
*bla bla bla*
}}
Just parse it in didReceiveRemoteNotification: method.
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.
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
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}}