Callback function for push notifications while app is killed (titanium iOS) - ios

I cant find a clear answer about this in the Titanium documentation. Is it possible to directly respond to a push notification while the app is killed ?
I know that the callback is called when you open the app trough the push notification. but is there a way to respond when the app is opened manually ?
I tried to use remote-notification as UIBackgroundModes, but this only helps for paused apps.
My goal is to show the push notification in a in-app message center.

You should never rely on push notifications to deliver you payloads, they are too limited for that. If the user receives 5 push notifications and opens the app via the app icon, you will never receive any of the payloads. If he opens the app via one of those notifications you will only receive that payload.
You could use silentpush:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Background_Services-section-37539664_iOSBackgroundServices-SilentPush
But the app should always query a back-end to get the actual data. That's how WhatsApp does it as well, as you can see when you open it via a notification it will then still fetch the message(s) form the server.

Related

Notify the app about remote push notification when the app is not running (terminated)

When app is not running (terminated NOT in background) and a remote push notifications is received, is there any way to inform the app about it so that the app can update something locally such as simple int counter?
I want to store something so that when the app is launched the next time, app knows that notification was received when app wasn't running and something needs to be done.
If user launches an app by tapping on a notification, obviously the app is notified about it through AppDelegate methods but these methods are never called if user launches an app by tapping on the app's icon.
To be aware of notification when user launches app by tapping on icon, i need some way to let app know that notification was received when app was in background.
There is no way you can achieve this with simple push notifications.
According to apple docs if the user has manually killed your application by swiping it out of memory, your app will never be started in the background to process data until after the user chooses to launch it again.
One solution to this problem is using VOIP push.
According to apple docs -
Your app is automatically relaunched if it’s not running when a VoIP
push is received.
But you need a strong reason for using it and apple may ask that before approving your app on the app store.
To read more about VOIP push please go through this doc - https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html
You can also be used the "Silent Push Notifications".Which are confirming that their is something available on the server, which you need to download to your app,The payload format of the Silent push notification is like
{ content-available:1 }
The Best part of the silent notification is that they do not notify the iPhone user
Here 1 is for their is something available to download from the server.
here below i have attached the apple's silent notification slide.
Your App is getting Refresh in the Background.

Handle the remote notification for chat application in iOS

BACKGROUND
I am buidling a chat messaging applicaiton and I faced a problem handling push notificaton when user receiving message from the sender.
WHAT I WANT TO ACHIEVE
Like Whatsapp does, after I received the push notification and I turned on the airplane mode, I still can see the message contents while I open the app. so, I believe it has gotten the message while receiving the notification.
PROBLEM
I cannot find a good way to handle the remote chat message push notification when the user opens the app through its icon on the home screen instead of pressing or doing another action on the notification.
WHAT I TRIED
I manually loaded the message when the app did apear, but this is not like the tested behavior on Whatsapp.
I tried this third party socket library, but iOS killed the listening service once the app was closed, it is not applicable to what I want to build.
MY QUESTION
If still using the push notification or background mode remote notification, is that any way to able to handle the push notification when the app is not running?
I also find out about the Apple PushKit, I not sure if this is only allowed for VoIP providing apps. Does anyone know if Apple will accept my app to be published to their AppStore if I use the PushKit for only text messaging?
The untimate question, how can Whatsapp achieve this? Does it use PushKit as well?
Actually you can't handle something when your app is killed, so simple solution for you problem is to store all push notifications data in server , get it from server when you run app, and delete them once you got them. I think Whatsapp handle this in same way.
Just search about XMPP server, for live chat there is no need for Pushkit, Pushkit is only for Video call notification when app is terminated.
Use XMPP server for live chat integration.
https://code.tutsplus.com/tutorials/building-a-jabber-client-for-ios-xmpp-setup--mobile-7190
What is XMPP, and how can I use it within an iOS chat application?

Notification - when app is killed

I have implemented AWS SNS push notification service.
We have an issue which is explained below :
Scenario :
We are trying to save the notification message we receive as a part of requirement.
When the app is killed (swipe out from recent apps) we are able to receive notification, also we are able to save the notification message when we open the message directly from the notification panel it works fine,but when we open the app directly the notification message is not getting saved.
In short we are not able to know if we had received a notification message if we directly open the app rather than clicking the message from the notification panel.
Is this default behavior ? or is there any work around for this ?
Have looked into many posts on about Push Notifications but haven't seen any threads pointing to this scenario.
This is a normal behavior, and there is no workaround.
If your app is killed by the user, it won't be able to run ANY code before it's manually launched again.
If it's manually launched from a notification, this notification's payload will be handled by your AppDelegate.
On top of that, don't forget that Push notifications are Best Effort. That means that they are not reliable, they can be heavily delayed or never delivered at all. Don't rely on Push notifications to achieve any critical work.
If you need to keep a copy of your notifications in-app, keep them server side and fetch them as you would do with any other object.
In order to execute code when the app is killed by the user you need to implement VOIP using PushKit framework provided by apple.
VOIP push unlike regular push notification enables the app to become active even if the app is killed by user.

How can I turn off push notifications of other apps when Im using my app

I created an app which receives push notifications from my server. At the same time, if some other app is sending push notifications (for e.g., whatsaap, twitter), the notification is getting displayed when I'm using my app. I want to hide all other app's push notifications except my app's push notifications. Can this be done in iOS? I want my app to receive push notifications only from my server but not from the other apps.
Thanks in advance.
Try to think like your customer. Would they like to receive the push notifications of the other apps (whatsapp, twitter, the notification that a very important email just arrived)? Of course they would. Your App is one of many and most probably not the most important one they own.
Let me provide some background first.
Your app can only receive notifications from your service/server.
The user might have apps that are receiving notifications from the respective service/server.
e.g. if the user has FB app, then it would be receiving notification from FB servers.
In the end, you are only responsible for managing your service/server.
There is no way for you to block notifications that are received from other services from your app.
Hope this helps.

Process received apple push notification in monotouch

Is there a way to show or list Apple push notifications on any user page?
It's pretty hard to find where is the alert message is received.
Here is the Xamarin doc for Remote Notifications: http://docs.xamarin.com/guides/cross-platform/application_fundamentals/notifications/ios/remote_notifications_in_ios/.
iOS handles the push notification for you, your app is only informed of a push notification if you app is running in the foreground or when the user clicks on the notification and you app is opened.
With the iOS SDK there is no way to get a list of notifications for you app, the best way to create this is by keep a list server side.
Have a look at MonoTouch.UIKit.UIApplicationDelegate.ReceivedRemoteNotification Method

Resources