Reputation: 424
I have a Xamarin iOS application that is configured to receive remote notifications. When a device receives a remote notification, the remote notification handler is not executing as expected.
The implementation of DidReceiveRemoteNotification includes a reference to the application, the notification user info dictionary, and a completion handler to be executed with the appropriate UIBackgroundFetchResult status.
public override void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
// retrieve something from a server somewhere
}
According to Apple's iOS developer documentation, the implementation of the 'application:didReceiveRemoteNotification:fetchCompletionHandler' will execute after displaying the remote notification to the user.
This includes when the application is in a running state, backgrounded state, as well as a 'not running' state. Receipt of the notification should launch the application and then put it into a backgrounded state before calling this method.
When running on my device, the remote notification is delivered successfully. However, when following the console log of the device in XCode Organizer, the app is never launched and the 'DidReceiveRemoteNotification' method is never executed.
I have done the following:
If this thread is correct, this looks like an issue in the Xamarin implementation, but I'm hoping someone else has run up against this before and can confirm or provide additional info. http://forums.xamarin.com/discussion/8765/handling-silent-remote-notifications
Upvotes: 2
Views: 4994
Reputation: 2572
AFAIK, DidReceiveRemoteNotification
will be called when your app is running and device received push-notification for your app.
When your app is launching from push-notification (i.e. it wasn't running before), you should read AppDelegate
s launchOptions
dictionary in didFinishLaunching
event.
For more information read what UIApplicationLaunchOptionsRemoteNotificationKey
key is.
Upvotes: 5