Add buttons to push notification alert - iphone

Is there a way to set up how users see the push notifications alert box? My notifications are appearing without the view / cancel buttons, but i'm receiving others from different apps with those buttons. Is that a setting i should set before sending the push notification?
Thanks!

There are two things going on in your question.
First, you will see no buttons at all when you receive Apple Push Notification alerts and your screen is locked. All Apps will have just the Title and the Message of the Alert, without the buttons. If your phone is unlocked, you will see the buttons.
Second, altering the Payload, you can customize the "View" button text (or remove it) Apple Push Documentation with the "action-loc-key" key. If you set it to null, only "OK" will be presented. If you specify a value, it must be a localized string in your Application and the "View" will be replaced with that value.

Check out the docs -- as you can send the name of the "open app" button in the push notification payload. Here's apples take on it

Related

is there a way to manage the duration of the remote notification to be displayed longer on the banner?

I am working on an App which I want the Playload notification to remain presented in the banner until the user clicks on it.
I have two cases:
App in background, after opening the app (not through the notification) the notification disappears.
App in foreground, the notification will be presented on the banner (I used: UNUserNotificationCenterDelegate for that) but after few seconds it disappears.
is there a way to manage the notification duration, I want it to be presented until the user clicks on it.
This is known as a Banner Style. It can be set to either Temporary or Persistent with persistent banners requiring user interaction to disappear. You can not manipulate the duration of your notifications being displayed on screen. The banner style for the application can only be changed by the user in the notification settings for your application:

localnotification is not displayed as popup

Is there any reason why my local notification is displayed in notification centre but not POPED up? Is there any setting to make it popup?
A local notification will be displaid as all other notifications, there is nothing you as a Developer can do about it.
The default settings for notification is to display them as a banner at the top of the screen, not like a alert view as in previous version of iOS.
Only the user can set the display style in the settings app notification section.

how to handle push notification by the kind of notification

i want to handle the notification, in my app i have 2 tabs(friends,jobs) with navigation controller,and a barbutton on each navigation controller named 'notification'(on click it displays tableview).
On notification, if its job related it shud open the page linked to barbutton on jobs tab and if it is friends related it shud open the page linked to barbutton on friends tab.
The notification contains a userInfo dictionary. The contents of this is set by the push provider. So assuming that you're also the provider of pushes to your app, you can just add a key to the userInfo dictionary that your app will read when the push arrives.

How can I remove the badge number if I click on close button in push notification?

I am working with push notifications. When I get a notification it comes with 2 button, view and close. If I click on view it opens the app and when I click the close button it does nothing but a badge number appears on the app icon. Then when I open my app again that badge number should disappear but it doesn't. How can I remove that badge number if user clicks on app icon? Thanx
put the following code somewhere in your applicationDidFinishLaunching or applicationDidBecomeActive.
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
What you could do is omit the badge key from your remote notification so that any badge number currently shown is removed. If you want a badge to show up if the user taps View, you can set a badge number using [UIApplication sharedApplication].applicationIconBadgeNumber.
But I'm not sure why you'd want to do this.

Push Notification Alert Handling

I have a doubt. I am building an application wherein if there is a new request is submitted I am getting a push notification in my application and on tap of "View" button in the push notification alert I need to show the request detail page. Now, normally this request detail page is 5th view in the stack. How should I handle this? Should I initialize first 4 views and put them on the stack before going to the detail page?
Also, there is a scenario where if someone is working on some part of the app and notification comes up. In that should I loose the changes on the currently opened page and show the request details if "View" was tapped on?
How should I handle this?
You can just push that view (the usual 5th view). The only thing is that when you pop that view, it will now act as the 2nd view, so theres no need to go through 4 additional views.
You can initialize and push the 5 views to your navigation controller (with animate:NO) to start the app up in the right place.
As for if you get a notification while running, that's really up to you and what is best for the app. You can always prompt the user before deleting any data. Note that if you get a push notification, your application:didReceiveRemoteNotification: instead of the alert showing.
This is commonly achieved by displaying the controller modally.
This way you don't have to recreate your view-controllers hierarchy and you don't lose the current context of your app if it was running. The user taps some "OK" button and returns to the previous screen.
For the first part of your question: if you have created your view in a decoupled way, that is, if it is not dependent on the 4 other views - i suppose then you can show this view without problems. Obviously the answer really depends whether your business rules allow this.
As for the second part of your question: you always can show an UIAlertView to your users asking whether they want to take action on the received push notification.
However - i think these problems really do not have anything to do with the nature of the push notifications, and you really should loose the "I have a doubt on push notification" part of your question :) ....
Hope this helps :)