Can push notification be sent without an alert for certain actions? - iphone

I know you can register to have alerts or not when you call the push notification API. However my problem is that I want a certain class of actions to have an alert notification while no alert notification for other class of action?
So for example, an alert should be shown when we send the notification "Heart rate dropping alert!". But no alert should be shown when we send the notification "downloading updated patient data", the app should just take the notification as an instruction to being download if it is launched. And simply ignore it if it is not launched.
How to implement this?

Check Silent Push Notifications for iOS 7.In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications.

You can embed custom JSON data in the push notification, look at The Notification Payload in the Apple docs.
Update: I don't think that quite answers your question. You can send a blank notification that has the effect of cancelling any previous push notification (including those from other applications). I'm not sure if the app gets notified of that when it is actually running. If it does you might be able to do that in conjunction with a custom JSON payload to achieve what you want?
{"aps": {"badge": 0}}
You probably know this already - you can't use a push notification to launch the app on the iPhone without the user seeing a popup (apps can never run in the background on the iPhone).
However, you can display a different popup message and include different JSON data in the notification. Then if the user presses the button to launch the app ("Start", or whatever you call the button on the right) that JSON data is passed into the app. Your app can then carry out a different action based on that data.

Not possible. Push notifications cannot initiate tasks - nothing can cause an app to execute without user action. Similar question to Can I use Push Notification for this. You can trigger a sound, a text alert, or a badge value. That's it.

Related

Can I delete a push notification from a device which have receive this push notification?

I have the following problem.
I look for a capability to delete a push notification from a device (iPhone respectively Apple Watch) but this device have receive the push notification.
The use case is that a USER A send a request to all available USER Bs. A push notification is send to all these USER Bs. At the moment the push notification arrive it will shown on their Apple Watch. One of the USER Bs answer that he accept this request. After he press the button to accept the request the notification should be deleted on all the other devices.
I really do not know a capability to do this.
But I know that you can handle this problem in Android as provide a unique ID for this notification. After that you can delete the other notifications with this particular ID.
Is their maybe a same way for iOS like it is provided in Android?
This doesn't really have anything to do with WatchKit/Apple Watch.
To answer your main question: no, you can't do this as it describe. Once you fire off a notification, it's in the user's hands to decide what they want to do with it.
As an alternative, you could maintain an "inbox" with every notification in your app and use the notification to prompt the user to check it. That way you could remove a notification from the inbox on the server side of things.

iphone push notification to trigger a method

I am not a developer as much as i am a project manager, i need to know more if the following is possible to help me decide the future of a project.
mainly my question is, can i trigger a certain method (function) in my application using the push notification ? so my app might be in the background (or not) and i want to send a push notification message that wakes the application and execute some piece of code.
if the answer is yes, can this be done without the user interaction ? so i mean without the user clicking on the push message ? to be some kind of automated, so i send the Push notification message, the iPhone receives it and execute the code, without the use interaction ?
i can set up my own APNS server if needed.
i am not looking for a code as much as i am looking for an answer if this can be done or not.
Thanks,
Yes, this is possible, as long as the user clicks on the notification. This could be done either with local notifications, or push notifications.
When an application is launched in response to a notification, the AppDelegate method application:didFinishLaunchingWithOptions: will have an option indicating the notification that precipitated the launch.
It cannot, to my knowledge, be achieved without user interaction.

When push notification comes, if the user click the app icon instead of clicking the notification to open this app

When push notification comes, it the user click the app icon instead of clicking the notification to open this app.
Then how can I get the notification payload?
As others have mentioned, you can't.
You can only get the payload when launching from Notification Center because it means the user is interested in that specific notification. If you choose to ignore the notification and open the app by pushing the icon, you won't be able to get the push payload.
They have seemingly designed the architecture in such a way as to prevent the processing of piled up push payloads (say that 10 times).
This is proven because they really only allow you to process a push payload (when the app is closed or in the background) by going through individual notifications. If this wasn't the case, they would have to allow push payload processing code to run for all apps even when they were closed or in the background state.

Can we cancel a push notification from application on iOS5?

On iOS5, the push notification shows on the top bar and not block user. When the push notification is showing and user click our application but not the push bar, our app will launch normally. However, we want to cancel the push notification at that time. Is it possible ? Thanks a lot!
Short answer: No. There is no way you can manipulate sent notifications as far as I know.
Slightly longer answer:
Once a push request has been sent to the Apple Push Notification servers, thats it. It disappears into their system and they will then try to deliver it on a 'best effort' basis. You receive no feedback about its status or any ability to change/delete it.
The only form of feedback you can get is about which devices do not wish to receive push notifications that you tried to send to.
If you want to send delayed notifications which can be cancelled/modified at later data, either write you own solution, or use some pre-existing solution (e.g Urban Airship).

Handling Push Notification While App is Open

I have my Push Notification running. It works. I receive a notification and use
application:didReceiveRemoteNotification:
to get the incoming data and then send the user to the necessary screen.
Problem is, if you are using the App and a notification is received, it jumps to the destination screen without giving any alert/sound/anything.
I could put an alert in application:didReceiveRemoteNotification:, but then that alert would appear every time, not just when the app is running.
Ideas about how to handle this?
I would recommend checking the applicationState property in UIApplication to determine if the app is running in the background or not.