I am working on an iphone messaging application so using APN Servers to send push notification to offline users (as whatsupp does).
I am using Enhanced Notification Format to connect APNs via an API (com.notnoop.apns 1.0.0.Beta7-SNAPSHOT version).
https://github.com/notnoop/java-apns
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/LegacyFormat.html
In some cases push notification is not delivered to some devices in a short period of time though everything works fine in my server application,
I mean pushnotification byte array is written APNs socket buffer without any problem.
At the same time whatsupp can receive push notification properly after that my client application starts receiving notifications from APNS servers.
I wonder if something is triggered in APNs after waiting 10 minutes and received whatsup notification.
I know that Delivery of notifications is a “best effort”, not guaranteed but when whatsupp can receive notification why my application sometimes cannot receive.
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW4
Here is my payload and other parameters:
Expiry:86400
Payload:
{"t":"-13","aps":{"content-available":1,"alert":{"loc-args":["Sender Name John"],"loc-key":"LS_NP"},"sound":"pnsound.aiff","badge":3},"n":"M","m":"NP","j":"905551114444"}
Why I am having this trouble some times? and What I need to check?
Does Apple have an reputation policy in which notification delivered to whatsapp is prioritized?
There is one more notification format (other than both simple and Enhanced)
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html
This format allows us setting priority format, is this format(IMMEDIATELY) get notification delivered 100%?
Related
We have developed an Android chat-app having Java Spring-boot as backend. We are using the Mesibo messaging platform. We need to develop a push notification feature. Also, we cannot use FCM as it is blocked in certain countries. Mesibo has provided a webhook and some events for sending a push notification.
How will I deliver messages to the user when the app is closed on the phone or the user is offline? Also, I am not sure how the backend will receive the event on which callback will be sent to Mesibo?
If FCM is blocked in countries, you need to have alternate mechanism to wake up your phone, for example, Baidu.
Set up your webhook in the mesibo console so that mesibo invokes it when there is a message or call for an offline user. You can then use (say, Baidu push) to wake up the phone. Once the phone comes out of sleep, mesibo can take over.
I am trying to implement push notification service for my new chat application. For the POC sake, I got my device registered a demo app with FCM and created an account for my app on FCM. That way, I am done with all the formalities. I am using XMPP protocol based implementation from google.
Now, when I try to send the push for more than 50 times in a single shot(using for loop) to my android device. FCM sends me the delivery receipt for all the push notifications (say if I am sending 60 push at times then it sends me delivery receipts for 60 push) but on my mobile I just get 49 push notifications.
I tried multiple ways like sending each PUSH after a gap of a second, but still getting 49 messages.
Can any one suggest me what shall I do to rectify it. I want to see all the push notifications on my device. I have gone through various links, but could not find any help.
The packet I am sending from my server
{
"delivery_receipt_requested":true,
"notification":{
"title":"XXX",
"body":"Message 111...0"
},
"data":{
"message":"This is the simple sample message"
},
"time_to_live":2000,
"message_id":"m-0-f21bb45d-213c-4306-b773-1f7f71d1494b",
"to":"SOME VALID DEVICE TOKEN"
}
Can someone please suggest if I am missing anything.
Thanks in advance.
There is a maximum count limit of notifications displaying for each app on Android.
So in your case you can receive all delivery receipt for the push notifications, meaning there is no problem for the device to receive them.
The main issue is the device can not display notifications beyond the limit, say 50 notifications.
Any notifications beyond the limit will not be shown on the notification area.
reference:
android system notification limit per app
I have done a small experiment on my mobile by developing a small app and a tool which sends push notification every 2 seconds using FCM to my app.App will be foreground and when i tap on setting in my app it will display the notification count my android app has received.
I sent around 1000 pushes and found that around 658 received on my mobile.So this assures that my mobile does receive the push more than 49 and FCM is not 100% reliable for the PUSH notifications.
Thanks
If sender is sending apns notifications to user successfully and suddenly user sets device to air plane mode or do not disturb mode then how does the sender know if the device has got the notification or not.
Will Apns notify of success or failure to the sender.
----Update to above question below,
is there a way for IOS app to tell the sending java client about the notifications received, without the user's action of launching the app or clicking one the notification.
For e.g. user might be busy and the device may be idle. In such case if a notification arrives, is there a way or API/Method in IOS to send acknowledgement to the sender, that notification with 'someID' is reviced in notification tray.
Reason being, if someOne wants to charge for notifications sent to a device. if user does not recieve it than it may cause problems.
You need to understand the concept of APNS properly. Have a look at the docs to understand it better :) Though, lemme add some key info here to help you :)
There are few wrong assumptions you have about APNS :)
Mistake 1
"If sender is sending apns notifications to user successfully"
I believe by that statement, you mean user using an app sends a APNS to other user using APNS :)
Sorry :) iOS client applications dont directly talk with APNS to send push notifications :) Request to send a push notification might generate at iOS client app (like user types a text and clicks on send) App wont directly make a call to APNS and handover the payload to it :) There is another important entity playing a very important role in background that is your App Server
What happens when I send a text to other user using APNS??
Your application should gather user text and send it to your Application server :) Your Application server then establishes a two way hand shake with APNS :) Once successful it creates the payload in perticular format :) gets the device ID's to which it has to send the data and sends it to APNS finally APNS delivers it to client apps :)
Mistake 2
Will Apns notify of success or failure to the sender.
Apple documentations clearly says APNS is a best effort service :) Which means APNS will not take any guarantee of delivering every single request sent to it :) and does not provide any feedback regarding the successful delivery of packages at client end :)
All the requests that your Application server sends to APNS gets queued and gets delivered when APNS is free to process them :) If request-1 is yet to be processed and request-2 comes from your application server to APNS request-1 will be discarded and request-2 will be processed :)
How to deal with this kind of situations then ?
Once receiving the message your receiver iOS app should talk with your application server and inform that it has received the message/package :)
Assume user 1 sends 2 message :) lets say message1 and message 2 :) now your application server sends message1 to APNS hoping that it will deliver the message :) If APNS sends it to user 2, user 2's app should talk with your app server and say hey I got message 1 :) Now when user 1 sends message 2 your application server knows that no messages are pending to send to user 2 :)
If user 1 sends message 3 and user 2 does not receive anything from APNS when user 1 again sends message 4 and user 2 informs that he has recieved message 4 your application server should be able to identify that it has not recieved the feed back for messge 3 so it should re-send it again :)
There are 100 other ways to keep your Client and server in sync :)
TIP
If you are developing chat app depending on APNS is not feasible solution :) Hope I guided you atleast with the concept :) Happy coding all the best
I want to implement push notification for Android and IOS, we have our own app for android and ios from that app user can send various request and after request completion user will get notification by using push notification.
So my question is
1. How I can detect the device to which i need to send notification.
2. I am new to GCM so can somebody help me from how to start this.
3. Every where I have found GCM send RegId to server, so whenever request comes every time I need to generate RegId or I need to check whether that user is registered or not if not register it first and then sends notification.
Thank You.
You don't need to regenerate the Registration ID every time.
In simple terms:
Client registers with GCM and client gets a registration ID.
You need to store the registration ID in your server.
Your server will need to send a list of registration ids with message content to GCM. GCM will respond with a list of successful and unsucessful messages to
the server.
The push events that are successful will go to the corresponding device. Note that the push notification will only show if you have
code on the client that receives it in addition you need to have the
app installed.
The client and server code example on the documentation is easy to implement. Have fun :)
I am using the Google-GCM service for pushing notifications to a mobile device & building this application in Java EE.
I'm perfectly able to push notifications to the mobile device. And from the client-end (mobile) I'm able to receive input(string).
Henceforth my conceptual question starts: When I'm receiving input from a mobile (let's say: "Hello, Server"), I'm trying to build an automated process on the server-side and in reply it will push a notification (let's say: "Hi client, I'm fine; How are you?") automatically.
I want to grab some idea to push the notification automatically whenever the mobile device is registered. How do I do it?
All realistic implementations of GCM include a stage where an app receives a RegID, and communicates the RegID back to the server, typically via an HTTP service, typically along with some other business specific data. The server would store the RegID, associating it with other data, and later use it to send messages.
Have you implemented automated the delivery of the GCM registration ID to the server yet? If so, in the same piece of code, you might as well push a notification back. If not, do put together some. Server-side implementation would depend on your server's platform, naturally.