End-to-end tracking of ios push notification [duplicate] - ios

I build xcode app that get push notification, the main problem is that the push notification is very critical for me.
so I want to check if the push notification is delivered to the device with the app installed, I understand that if the iphone dosn't have internet connecction / 3G the push notification is not getting to the device.
how can I check if the device get the notification or not?
how can I check if the APNS successful to deliver the push notification?
I want to send sms if the push notification is not deliver to the device so I think about the idea to get the notification event when it's open by the push notification, and to send request to my server so i can know if the push notification is successful deliver or not. the main problem is that the user need to open the app every time he get the notification and in the night it's a problem. so this option is not good for me.
I check the feedback server push notification but i don't find any info that I can get if the push notification is delivered or not
any idea??

With iOS7 you have a new method called
application:didReceiveRemoteNotification:fetchCompletionHandler:
which you probably could use for your task. From Apple's Docs:
Implement this method if your app supports the remote-notification background mode.
...
When a push notification arrives, the system displays the notification to the user and
launches the app in the background (if needed) so that it can call this method. Use this
method to download any data related to the push notification. When your method is done,
call the block in the handler parameter.
Unlike the application:didReceiveRemoteNotification: method, which is called only when
your app is running, the system calls this method regardless of the state of your app.

The short answer, you can't, since APNS is one way. However, since an app can execute arbitrary code upon receipt of a notification, you can use this to say, send an http request to your own server when the notification is recieved.

There are any number of reason why push notifications might not get delivered to your user, or might not be delivered in a timely manner. Apple does not provide any mechanism for you to query the status of a push notification that you have sent.
If your app is currently running on the user's device and the user is accepting notifications for your app, you can implement the following method in your app delegate. It would be called whenever a push notification is received and in this method you could send a request back to your server to indicate the message was received. However this will only work while the user is running your app.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
In general though, it sounds like you'e relying on push notifications for something you shouldn't. From Apple's Local and Push Notification Programming Guide:
Important Because delivery is not guaranteed, you should not depend on
the remote-notifications facility for delivering critical data to an
application via the payload. And never include sensitive data in the
payload. You should use it only to notify the user that new data is
available.

There is no way to find out whether the notification was delivered to the device or no. APNS is a one way service. If there is no internet connection on the device then the APNS server will hold the last notification for some period of time which is no specified by Apple. If a new notification is sent to APNS for delivery then the old notification data is lost and replaced by the new data if its undelivered. If the notification is delivered then also the old notification data is deleted on the APNS server.
Please go through the following link : Apple Push Notification
Hope this helps you...........

If you are using JAVAPNS to send the APNS notification, you can use the below:
List<PushedNotification> notifications =
Push.combined("alert", badge, "default", "cert.p12", "certpassword", true, deviceToken);
for (PushedNotification notification : notifications) {
if (notification.isSuccessful()) {
//Push is successful. Do your thing...
}
else {
//Push is not successful. Do your thing...
}
}

Related

How to get all the push notification payloads after an iOS app launches or did become active

I have an app to work on. And I need to know if there is already some push notifications before the app is opened. Is there a way to solving the issue?
Thanks
You can't push a notification to a device when your application hasn't been opened at least once - the user has to authorize push notifications and you need get the push token value - returned after calling registerForRemoteNotifications - and send it to your server.
There's no guarantee that your app will see multiple push notifications if they all arrived when the application wasn't running. Often you'll just see the most recent notification. You should store all of the notifications on your server and have your application request them when it becomes active if there's at least one notification waiting for you.
Once you've registered for notifications you need to setup didReceiveRemoteNotification method in your AppDelegate. There you can handle any information received from a Push Notification. Here's a link to there relevant documentation.

Push notification on iOS devices

I’m able to send and receive the push notification…In the push notification i will be sending some json encoded data…
Once my device receives the push notification,then if the user taps on the notification banner device can get the json data received by the push notification.…But what if user clears the notification banner,how can the iOS device receive the json data?…Any suggestion guys?…
You can set the content-available flag to 1 and iOS will call your app's delegate.
There are just 2 ways to get push notification details, when application is not working. First one is not very reliable since it will provide you latest push notification only. Second one, you can't really use if you want banner and you want to notify user. Third one is just an alternate way to get latest updates from server.
Get details of last push notification in application Launch method :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *dicAPNS = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
Use silent Push notification, where user wont get any notification but you will be able to get notified. This is done by sending "content-available:1" in APNS Payload.
Call an server call to check if you have any update. So you can grab data from server what you might have received in missed push notification.
I think iOS push notification fully depends on user's wish.I think the another web service needs to load all the content of data in push notification, if push notification is disabled or deleted by user.

iOS Push Notification - check if the banner is showing when app is in background

I have a VoIP app, where the incoming call notification is very important.
The problem is, sometimes I don't get the push notification (even Apple said it's not guaranteed). But, I do have a mechanism to notice that an call is coming while the app is in the background.
So, what I want to do is.. still use Push Notification as the main handler for incoming call (because it handles the situation when app is closed). However, if the push notification failed to deliver and my app gets the call invite, I will raise a local notification, telling user that you have an incoming call.
My question is... how can I check if a notification is showing before I decide whether to fire a local notification?
AFAIK you can only detect the notification when the user taps on the banner OR if the app is open when the notification comes. So I can't see a way to detect if the notification has come yet or not. Just adding to the pain, push notification is famous for its unreliability.
There’s no API to get any information about the state of your notifications. Since you’re making a VoIP app, you have the option to have it get woken up for incoming data, which would let you post your “incoming call” notification whenever you need it—see the “Configuring Sockets for VoIP Usage” section here.

Apple push notification-like service, only when running in foreground

I have an iOS app that needs to update its content while running in foreground automatically. My app does NOT need to update if in background.
There is a existing way to do so, which is APNS(Apple Push Notification Service).
Because I don't want users to see notification message while in background, using push notification without alert or message might be a solution.
However, if using APNS, iOS would ask users to confirm if they want to receive notifications by my app. I think that users may be confused when being asked by the OS since my app does not actually push notification to users.
The current method I use is keep pulling my API every 30 seconds to see if new content is available. This method would fail if there are too many users.
Is there any 3rd party push-notification-like service that provides notification while app runs in foreground only? (no need to get notification while in background)
You can use Silent notification for that, in this
In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications. if you send the APS payload with just the content-available set to 1, users will not be notified of the notification.
And the notification arrives in application:didReceiveRemoteNotification:fetchCompletionHandler:
Your payload is like
{
aps: {
content-available: 1,
sound: "default"
}
}
In case of push notification, it is necessary for user to accept push notification on application 1st run. You can set a silent push notification also and for this user will not get any alert of getting a notification during application run loop.
If you want to avoid push notification, then you can only set a NSTimer that you are doing already.
There can be a 3rd case, Application only sync with the server when it comes to foreground. And for this you can refer to my this post.

How to start an iOS push notification from an in-app process

I'm building an app that plugs into a third-party service that will send messages to the iOS device. So far I've been unable to find any documentation on then starting off a push notification when the delegate method is fired to say that a new message has been received.
So far, I've got the app registering to receive push notifications and the delegate method firing, I'm just not sure how to connect the two together?
The app will have a minimum deployment of iOS 5.1 if that helps.
This is not how remote notifications work. Their main purpose is to notify application about some event. So application only receives remote notifications and note send them. So scenario is:
App is notified via
application:didReceiveRemoteNotification: //if running
or
application:didFinishLaunchingWithOptions: //if closed
According to notification payload you determine what exact action you need to perform. For example notification says that a new message was sent to the user. Then you need to send your custom request to the your server and get that new message.
I've discovered that in this case it is not push notifications that I want but local notifications instead.

Resources