Push notification is not showing 2kb in ios 9 - ios

Check this following push notification response. I have passed longer text in the "alert", but it is cut to "Riddham Pan". It exceeds the limit of payload.
Can any one please tell me how they counted 256 bytes in the following notification.
I am checking in ios 9 so limit should be 2kb. Do I have to do any custom settings in code for getting the notification upto 2kb length?
{
EmailID = "";
Message = "";
NotificationType = Offline;
RefId = 0;
RefType = "3f588d5b-dbbd-4a65-b800-d863f8eb684d#conference.dev.time.appleapps.in";
UserName = New1;
aps = {
alert = "Riddham Pan";
badge = 2;
"content-available" = 1;
sound = "sms-received5.caf";
};
}
Thanks in advance.

The JSON is invalid. If payload limit exceeds than 2kb notification would not be handled. From Apple docs
Apple Push Notification service refuses any notification that exceeds this limit.
Reference
Since you are receiving notifications this means your payload limit is not exceeding but JSON format is invalid.

Related

ios 13 push-notification gets cleared as soon as we get when device is locked

when I'm receiving push notification on iOS 13, and device is locked. I' getting pushnotifcation, but it gets cleared immediately without any user interaction.
I'm using .net and following is payload code which I'm using
{to = notification.DeviceToken,
priority = "high",
content_available = true,
notification = new
{
body = notification.Message, //This will be a subtitle..
title = notification.Name, //This will be a title..
},
data = new
{
notificationId = notification.NotificationId,
userId = notification.UserId,
encryptedNotification = Crypto.Encrypt("id", notification.NotificationId.ToString())
}
};
string postbody = JsonConvert.SerializeObject(payload).ToString();
Byte[] byteArray = Encoding.UTF8.GetBytes(postbody);
tRequest.ContentLength = byteArray.Length;
**tRequest.Headers.Add("apns-push-type", "alert");**
**tRequest.Headers.Add("apns-priority", "5");**
}```
Please guide me what wrong in code.
have referred following azure code to implement, but not able to find the cause.
https://learn.microsoft.com/en-us/azure/notification-hubs/push-notification-updates-ios-13
This can happen if you have a code that decreases the app icon's notification badge number. If you do that, make sure you do it only if the application is active. If it is inactive and you decrease the badge number, it might cause the notification to appear and immediately disappear.

Xamarin IOS Push Killed app

Push =>
{{
aps = {
alert = {
"loc-args" = (
);
"loc-key" = "new_chat";
};
"content-available" = 1;
id = 3;
message = Aaa;
sound = default;
subject = "new_chat";
type = chat;
};
}}
When the application is killed and I receive a push notification it is shown with the text "new_chat". How can I change it to another text?
Assuming you are targeting iOS 10+, you can add a Notification Services extension app (UNNotificationServiceExtension) to your app bundle.
modifies the content of a remote notification before it is delivered to the user.
In the DidReceiveNotificationRequest override, extract your content from the UNNotificationRequest and modify it and return it via the contentHandler provided.
Required reading to understand how/when the extension is used:
Modifying Content in Newly Delivered Notifications
Also:
Xamarin Docs: iOS Extensions in Xamarin.iOS
Apple docs: UNNotificationServiceExtension

How to reset the Badge app icon number?

I integrated the Push Notification to the CloudKit so that every change in the iCloud will pop up a notification on my iPhone and the badge app icon number will add one correspondingly. However, when I used the code:
application.applicationIconBadgeNumber = 0
to reset that number in the applicationDidBecomeActive(_ application: UIApplication), I noticed that the badge app icon number truly disappeared but if another new notification came again, the number won't start from one again as supposed but just add one to the original total number before the reset. Therefore the number is getting bigger and bigger. I wonder how to solve this problem?
The problem is your apns payload, it contains badge count more than 1, you need to reset the payload as well.
When you set application.applicationIconBadgeNumber = 0 it just resets the badge count locally, not in the server.
Solution would be reset the badge count for the user in the server too.
Update: Apns Payload
{
"aps" : {
"alert" : {
"title" : "Push",
"body" : "Hello User"
},
"badge" : 5
}
}
The app shows the badge count same as in the apns payload above, you need to reset the badge value in the payload above from server.
Hope it helps.
Cheers.
I find that I should not only set the application side like:
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
but I should also set the iCloud side in CKContainer. Therefore, the complete code is like below:
let operation = CKModifyBadgeOperation(badgeValue: 0)
operation.modifyBadgeCompletionBlock = {(error) in
if let error = error{
print("\(error)")
return
}
application.applicationIconBadgeNumber = 0
}
CKContainer.default().add(operation)

Firebase message (FCM) not work in close app

This Post is referenced by FCM.
If the application is active state or in background state then all is well it's working fine.
But if you close(Terminate) the application. The messages do not come, that I would not do it.
Priority is high in messages.
Messages like :
act = msg;
aps = {
"content-available" = 1;
};
"chat_id" = 26;
date = "2016-08-23 08:05:21";
delay = 300;
"from_user" = 25;
"gcm.message_id" = "0:1471939....f965049af";
id = 898;
"is_read" = 0;
msg = sds;
type = 1;
How to make that message come close application?
Just ran many tests. It appears that in order to have the message delivered to a "closed" IOS app, you need to specific priority=high. With priority unspecified or set to "normal" it will not deliver the notification to a closed app. When the app restarts, it seems the undelivered messages will be sent and handled in the same way as if the app were in the foreground when they were sent originally.

Can't Get GCM Notification from background ios sdk

I can't get GCM notification from background, Although can receive it on foreground such as these:
{
aps = {
alert = {
body = fffff;
title = "\U067e\U06cc\U0627\U0645";
};
badge = 9;
sound = default;
};
"gcm.message_id" = "0:1448218309944532%075c2cd9075c2cd9";
}
Any help?
To get notifications in background, as per apple documentation
"Remote notifications" option needs to be enabled in Background modes under Capabilities in the target settings.
and normally when you receive any notification at that time application:didReceiveRemoteNotification: this method called.
and if you want to call this method in background, then you should sent a silent pushnotification. and for that you have to add content-available key with value 1 into the notification payload.
you JSON response contain that key like below example
{
aps = {
"content-available" : 1,
sound : ""
};
}

Resources