Push Notification Object - iphone

My app receives push notifications and sometimes these notifications come with an object that has to be stored on core data.
What happens if one of these notifications with an object arrives to the application when it is not running?
How do I handle that?
thanks

If you have implemented method
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{}
It will be fired up for every notification during the sleep, when the app becomes active.

Related

IOS urban Airship. How to Handling notifications

I am pretty new to this. I implemented the Urban Airship push notification and its working properly. Now I need to implement how to handle a push notication. I would like to show a tab or when the user clicks on the notification.
Appreciate any help.
Here is the instruction from urban airship and I dont know how to implement UAPushNotificationDelegate.
Handling notifications
iOS handles push notifications received outside the application, but if a notification is received while the app is running, it is up to the application developer to handle it.
The sample UI includes an implementation of UAPushNotificationDelegate that handles alerts, sounds and badges, however if you wish to customize this behavior, you can provide your own implementation:
[UAPush shared].delegate = customPushDelegate;
You would listen for an app delegate method and handle the notification:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if ( application.applicationState == UIApplicationStateActive )
{
//do your handling here
}
}
If you pass in custom json objects you would also parse it here

How to post push notifications in APNS and how to show the notifications in iPhone?

I have several doubts about APNS. Am trying myself to make clear on the APNS but still need some clarifications. I have to know how we are posting push notification in APN Server and how we push the notification to Apple APN Server? And also how am i receive the notification from Apple and show the notification to user? I know we are receive the Notifications from below delegate,
-(void)application:(UIApplication *)app didReceiveRemoteNotification:(NSDictionary *)userInfo
How we should show the notifications to the user, please suggest any sample codes? Please clarify my silly doubts. Thanks in advance. Please help me.
this tutorial is useful please see
http://mobiforge.com/developing/story/programming-apple-push-notification-services
when you receive push notificaion ,please NSLog userInfo
-(void)application:(UIApplication *)app didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NsLog("%#",userInfo);
}
push notificaion is come only one time , pop is open for about 10 second(Depend on notifcation type)... if you click then didReceiveRemoteNotification delegte is call , if you can't click any reason you see notificaion by go to setting->notification click...and check
if you want store total push notifaction use the database and store in your database

any option to know if apple app get the push notification?

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...
}
}

Multiple push notifications on 1 device - iPhone

How to handle multiple push notifications on One device e.g:
A user receives a notification saying you have 1 new message from my app. Before he checks that message another message comes in so now he has 2. Well I don't want 2 messages stacked in the notification bar, I want 1 notification saying there are 2 messages waiting. How do I implement this?
And also if on device got 5 new notification and user taps last notification then how we got the previous notification userInfo
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Regarding your first question, you won't be able to do this. Notifications are seperate events, and NotificationCenter won't (and can't) merge them.
Push notifications aren't meant to deliver (much) information, hence, you cannot rely on reading the userInfo objects. For example, what would you do if the user just closes the notification alert and deletes it without reading it?
What you should do is only use Push notifications to tell your app that "something has happened". The app should then fetch the information from the server. I.e, if the user taps on the last notification, the app will still download all the information linked to all five notifications.

iOS - Handling pushed notifications with APNS

Considering that I receive a pushed notification on my iPhone.
What happens:
If the application is started: is there a way to get the payload? Do I see the notification on my screen?
If the application is not started, is there a way to get the payload?
Thx for your answers
First of all push notifications are not “strong”, if you simply let a notification sit for long enough (e.g. phone turned off for many days) it will get discarded. You need to do some custom back-end processing to persist the content sent in notifications.
In the UIApplicationDelegate protocol there’s application:didFinishLaunchingWithOptions:. If your app is launched by the user tapping the right button in an alert of a push notification, the launchOptions dictionary bound to the method call will contain information regarding that notification; if your app is already running then application:didReceiveRemoteNotification: (also in the delegate protocol) will get called instead.
So,
If the application is started, and you implement application:didReceiveRemoteNotification: then yes you get the payload. Otherwise, nothing happens.
If the application is not started at the time the notification is sent, then the user taps on the alert of the notification and launches your app, your app gets the payload if it implements application:didFinishLaunchingWithOptions:. Otherwise, you get nothing.