React To PushNotification Received even if the App is Closed - swift2

I know there are a lot of questions related to this subject, but after searching I found out that they all say that if the app is closed then the only way is to fetch the notification again from the server once the app is opened or if the app is opened from the notification then you can handle it in didFinishWithLaunch but using WhatsApp, this is not the case...
I tried sending a message to phone B (which had whatsapp closed), Phone B received the notification. Then I turned off the internet on Phone B and opened the app and still received the chat message.
Can anyone guide me on how to do this?

Probably you should use one of background modes - "remote-notification".
After enabling it, you can send push with payload like
{
"alert": "",
"badge": "0",
"content-available": 1,
"sound": ""
}
if you specify content-available key equal 1, iOS will wake your app and call application:didReceiveRemoteNotification:fetchCompletionHandler: in app delegate and you have some time to proceed push and prepare app (like download this new message to device). Here is Apple docs link with info about push payloads.
However please be aware that this push delivering is not guaranteed. Apple tells
(Newsstand apps are guaranteed to be able to receive at least one push with this key per 24-hour window.)
In our experience you likely receive it most of the time, but not always. For example app delegate callback will not be called if user swiped to close your app.
Also you need to finish execution in 30 seconds or less and call the block in handler parameter (you can check discussion section of method documentation for more details)

Related

How messenger works in sync with multiple devices

I am trying to introduce a messenger (chat) feature in my application.
I ma unable to figure out how to make the feature sync on multiple devices.
Let's say I am using the chat on my phone, and then I login to my desktop and start chatting there. How would I get the messages on both devices and how will both be in sync with each other. Additionally, for the sender to get a read confirmation, the message should be read from either one of the device, but the notification of unread should be shown on sender's device on which the message in unread unless he opens and reads it.
For First Part of the question you want to do Like FB Messenger where you loggin you will find your whole messages found not related to a device. To Achieve that you can have at the device app Last Login time which will be posted to the server, and all messages from that time will be retrieved to the user. But imagine the user has read all his messages from the mobile but he didnt open the computer since one Month. IF you didnt mark the message as read, he will find enourmous amount of messages coming as unread but he actually read on his mobile which will cause you huge usability issue.
For your Case I feel you need to do exaclty what FB Messenger does. Retrieve your latest messages from your conv with their actual status. And while scrolling up load by demand.
So Your Message will have only 1 Status(Read or UnRead) And date where you can match with Device Last Sync time.

Xamarin iOS - How to make sure messaging app is up to date?

I have set background fetch to the app. But, It is not called all the time (it depends on how often the app is used by the user)
This is what want to do: When someone send a message to me, I need to make sure that my phone receives the message. Right now, I am using APNS (which works well is the phone is online and working). But, let's say the phone is off or internet not working, the user will never know that a new message has been received, unless he opens the app.
Is there anyway to make sure that, as soon as the user CAN be informed that a new message has been sent, a notification will be displayed on his phone? Right now, if the phone is off and a message sent, if I turn it on, nothing will happen.

Using Swift 2 won't allow iOS 8 devices to Register for Push Notifications

I am configuring push notifications on for iOS using Xcode 7 and Parse. The notifications are working perfectly on a device running iOS 9.
But when running the application on a device with iOS 8, I am running into problems. I am unable to get the Alert View where the user can select to "Allow Notifications from App X".
But, the device token registration call is being called successfully when the user opts in to push notifications and the device is successfully registering an Installation object with a valid device token. Notifications are also being sent to the device.
If I go into Settings->Notifications->My App and turn the Notifications On or Off, it doesnt make a difference the notifications are still being sent through.
This is the code I am using to register for notifications:
let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType([.Alert, .Badge, .Sound]), categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
Found the solution here on stackoverflow... Registration for notifications are sent only once on devices running versions older than iOS 9.
As answered by another user here...
"The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day."
OR
"If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on."
Reference Links:
Push Notification ON or OFF Checking in iOS
https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42

Custom Push Notifications

I am building a very basic information based app (Android) for an event, and i'd greatly appreciate your help on the questions below.
Basically, the app will just contain information about the 7 guest speakers at the event.
The attendees (2500 android users) will only get the link to the Android app when they arrive at the venue.
There is no database connected to the app as it just contains static information about the speakers which is hard coded into the app, however i want to build in a small feature so that i can send out custom push notifications to all users (let's assume 2500) at various times, such as when a speak is about to start on stage etc.
QUESTIONS
01 - am i right in saying that Parse allows you to send out custom push notifications in bulk from the Parse dashboard?
02 - is it able to send to 2500 at one time or do they need to be sent out in smaller batches?
03 - at what stage do charges start to occur for all of these custom push notifications
Thanks in advance for your help, it's much appreciated.
01. Yes Parse dashboard enables you to send push notifications in bulk.
02. Yes it is able to send as many push notifications as needed you needn't worry about batches since Parse dashboard is a simple GUI frontend made by Parse.com so you don't do any coding.
03. You can see on this link https://parse.com/plans that per app you have 1 million unique pushes. Unique push is equal to 1 push on 1 device. To be clearer a single user might have 5 devices registered to him so sending a push to 1 user does not mean 1 push but 5 pushes 1 for each device.
**One more thing to note if you are going to be making custom pushes you should think about handling the push notification in the Android app if you plan on doing anything fancy. If its just to show the push with text then you need the basic handling of an incoming push that does nothing once the app is opened by a push notification.

Windows Phone 7 - Is it possible to add additional key/values to push notifications messages

I'm testing out Windows Phone 7.5 push notifications. I have got the 3 different push types working fine (Toast, Tile and Raw) and am able to send messages from unit tests and a web application without any problems and receive them in my WP application. I want the ability to add extra properties to the push notification and the Raw push type does this perfectly for me and I can add custom key/value pairs or anything else to the push message and extract it on the phone app. I have just found out however that it only works if the application is running and my unit tests fail (suppressed notification status is received in unit test) when the phone application is not running (checked documentation which confirms this too). Is there anyway to add extra properties (key/values) to toast or tile messages or some way I can use raw in another way ? Toast notifications seem limited to a title property and an actual message property but I need to add additional data.
Just wondering if anyone had any suggestions / workarounds ?
The general practice I use is to initially send a raw notification to the device with phone-usable data embedded in the message. If my application is currently running then I can process the contents of the raw message and immediately make use of it on the phone. However if the application is not currently running on the phone you will receive notification from the push servers that the message could not be delievered. If I receive this response I send out a Toast / Tile notification.
With Toast notifications the only parametrisation you have access to is the URI that will launch the application. This is specified with the wp:param node of the message. Eg.
<wp:Notification xmlns:wp="WPNotification">
<wp:Toast>
<wp:Text1>Toast Title</wp:Text1>
<wp:Text2>Toast sub title</wp:Text2>
<wp:Param>/MainPage.xaml?LaunchedFrom=A%20Toast%20Notification</wp:Param>
</wp:Toast>
</wp:Notification>
If the user taps on this toast notification your application will launch and navigate to MainPage.xaml. You can access the querystring passed in via the NavigationContext.QueryString.
Note: The wp:Param node can only be sent to Mango (and up) devices. Additionally the entire contents must be less than 256 characters or you'll receive a PushErrorTypeMessageBadContent error. (Thanks to Ritch Melton for pointing this out). More info available from the Sending Push Notifications for Windows Phone page on MSDN.
As you've discovered, the Microsoft Push Notification Service is very strict in what types of messages you can send and receive. The intent of these push notifications is to provide simple push updates and not large amounts of data. The flexible Raw type seems like it would fit the bill until you discover that:
You can use a raw notification to send information to your application. If your application is not currently running, the raw notification is discarded on the Microsoft Push Notification Service and is not delivered to the device.
However, if you send a toast notification to your application, when the user clicks on the toast the application is started. When your application starts, you should check a service and retrieve the data you are trying to send from a web-service or other remote mechanism.

Resources