Im developing an app that uses Ibm Mobile First Push Notification on iOS.
My question is how do i detect the app is open or navigate to, when user click on the notification banner at notification centre?
I know WL.Client.Push.onMessage does the trick. But this function is being fired too when the app is at foreground and a notification is received.
Is there a different function?
Thanks in advance.
In all cases (app closed, opened, etc...), there is a single function/callback that is called to process the incoming notification.
If I understand your scenario, you want to perform a different action with the notification, depending if the app is opened or not? Perhaps you can resolve this by setting boolean flags during runtime or assign "IDs" to the various app screens and check for the values of these and act upon them accordingly?
Related
I have a question,
I work on a Swift 3 project with Xcode.
My goal is to send an alert sms, 20 secondes after receiving a local notification. when I'm in application, every things work well, but when my app is in background, it can do other tasks, like print some character, or play music, or send a text to a socket server, but it can't send the sms.
I think, when I receive an alert, if I could back to my application automatically, then I can send an alert sms, that's why I'm doing this stupide idea and looking for a way to know how I can wake up automatically my application and go back to the first View Controller Screen when I receive a Local Notification?
Maybe there is someone who knows a method to return to the iOS application automatically?
When your app is launched into the background—usually to handle some type of background event—the launch cycle changes slightly as given in the picture below. The main difference is that instead of your app being made active, it enters the background state to handle the event and may be suspended at some point after that. When launching into the background, the system still loads your app’s user interface files but it does not display the app’s window.
Reference - https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StrategiesforHandlingAppStateTransitions/StrategiesforHandlingAppStateTransitions.html
Bringing your app from background to foreground is not possible. And even if you are able to do so, App store will reject it.
Hope it helps!
I am creating an IOS application that makes use of PUSH notifications. When I send a PN, I send data to my application. IF my app is not active, I can then click the notification in the notification center to update the data in the app. However, IF I do not click the notification and I just resume the app via the launch screen, the app does not update correctly. Is there a way to update the apps pending notifications even if I don't press the notification center button and I just resume the app from the launch icon?
I have been scouring the internet with no luck. I have also tried to put the notification in a NSMUtable Array in the application delegate with no luck.
thank you in advance.
Without you having a list of notifications that the app can download from the server you won't have a consistent solution so that is the best bet.
If you turned on background fetch for your notifications then the app could maintain a list of the received notifications, but this approach would fail for any notifications coming in after the user had force quit the app.
I have developed the iPad app which uses apple push notification. Push notification delivering works fine in all the scenario except when the iPad device is locked and notification is delivered. In this scenario it behaves weirdly and opens the app when you slide to unlock the device without touching the alert/banner. Its happening in iOS versions 4.3, 5.1 and also in 6.0
In apple document they have mentioned as below:
http://developer.apple.com/library/ios/#DOCUMENTATION/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html
iOS Note: If the user unlocks the device shortly after a remote-notification alert is displayed, the operating system automatically triggers the action associated with the alert. (This behavior is consistent with SMS and calendar alerts.) This makes it even more important that actions related to remote notifications do not have destructive consequences. A user should always make decisions that result in the destruction of data in the context of the application that stores the data.
what is the action associated with alert?
the operating system automatically triggers the action associated with the alert
And also I wanted understand what is the default behavior in this scenario?
Any help is appreciated and thanks in advance.
It is not behaving weirdly, as that is the default behaviour. When your notification lights up the screen, the 'slide to unlock' changes into 'slide to view', which will open your app and execute the action related to your notification.
The default action is that nothing happens if you do not specify anything to happen.
For handling a notification (which is the action associated with the alert) please refer to the documentation: Link, section Handling Local and Remote Notifications
Is it possible to wake up a background application with a non ios notification center? e.g. if I were creating a calling or messaging application is it possible to wake the application via SMS.
Nope. If you want to call app outside the device, you should use APNS. On the device you can use local notification. Sending SMS to wake up app is kinda wrong. People don't like such solutions - imagine bunch of SMS every day for different apps. Sorry.
No.
If you have background code running, you can schedule a local notification to yourself. If the user clicks "Ok" then you will come to the foreground. See here for a description and sample code.
As far as I can tell, the only ways to launch an app without user input is via a custom URL handler or via an accessory. It doesn't sound like an accessory fits your use case. Sadly you can't open URLs from the background, so you can't use this to wake yourself.
What are the requirements and how would I go about implementing the Application Push Notification Service to trigger methods when the application is in the background, or when the phone is closed. Would this even be possible?
Thank you
No thats not possible.
When the app is in the foreground it will receive the push notification directly and can do whatever it wants to in response to that.
However when its not in the foreground the notification is displayed to the user (if they haven't disabled them) and/or displayed in the notification center (if they haven't disabled that). Your app will be brought to the foreground to execute if and only if the user selects the notification.
The application does not receive the notification directly if its not in the foreground.
Read the Apple Docs:
http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194-CH1-SW1
It boils down to lots of setup, and then implementing application:didReceiveRemoteNotification. You can read an in-depth example here. Part two goes into the actual application:didReceiveRemoteNotification implementation.