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?
Related
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.
On Android, when supplying the same id in two calls to NotificationManager.notify, only one notification will be shown in the notification drawer.
But how to do it on iOS
Thanks
Notifications on iOS are not designed to be grouped/collapsed or replaced by other notifications. Just check other messenger apps, the convention is to have a separate notification for each message, contrary to Android. Also a message doesn't get replaced by a new message in the same conversation. The functionality that Android provides here simply doesn't exist in iOS.
What you could do instead is, to send silent notifications ("push-to-sync") and handle the grouping/replacing on client side, since you have more control over local notifications (e.g. you can remove single local notifications, but not single remote notifications). But keep in mind, if the app was force quit, it won't be woken up to process the silent notification.
I think your best option is to stick to the convention and don't group/replace notifications.
about iOS you have to understand many things about the push notification
first it is not part of your app, in iOS it is separate application called notification centre that your app add itself to it so when APNS send a notification it send it to the notification centre in your iPhone not to your app.
so what you need to do will be in the server side not in the mobile side
for example let's say it is a chat application
the server side should check if the message is sent from the same user
the badge count should remain the same and not to notify APNS with new count
and also in the server side
the server will check if the message from the same user to send only sound notification not text or if the server got many message at once from the same user send the text with got many message from same user
but all of that is just work around as something like this is not provided yet in iOS may be in iOS9 as it become more open and not like previous versions
good luck
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.
We are developing a chat application like WhatsApp. It's XMPP based application, the XMPP complaint servers are follows push model for sending the messages, presence..etc.
So when user is offline the messages goes into offline stack and pushes again once user comes into online.
We want know that when app is killed , Can we use voip capabilities to run in background? or we really need go push notification model?
Please help Me .
You cannot add VOIP for chat application but there are other background task execution options by which you can achieve this.
Modify your server side piece send notifications to the app at reasonable time intervals if user if not online and your app will get opportunity to execute in background when these notifications are delivered.
Yes Apple will reject your app if you use VOIP Capability in chat app(WhatsApp like application)
if are you trying to use in background with help of VOIP but you primary not implemented VOIP functionality then apple will reject your app i tried before this for my streaming music player.
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