Im currently working on xamarin form ios app push notification. if app is closed(swiped) then DidReceiveRemoteNotification does not calls.
data payload is like below in server side,
private void SendMessage(string[] MessageTokenArray, string TextMessage)
{
var dataIOS = new
{
// to = MessageToken,
registration_ids = MessageTokenIOS,
content_available = true,
priority = "high",
data = new
{
body = body1,
title = eventname,
click_action = "OPEN_ACTIVITY_1",
priority = "high",
tag = "\"1\""
},
notification = new
{
title = eventname,
text = TextMessage,
sound = 1,
vibrate = 1,
},
};
SendNotificationn(dataIOS);
}
}
in xamarin ios
public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
CrossFirebasePushNotification.Current.RegisterForPushNotifications();
FirebasePushNotificationManager.Initialize(options, true);
FirebasePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Badge | UNNotificationPresentationOptions.Sound;
CrossFirebasePushNotification.Current.OnTokenRefresh += async (s, p) =>
{
//save token in server db
};
CrossFirebasePushNotification.Current.OnNotificationReceived += async (s, p) =>
{
//save data in local db
};
CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
{
//do something
};
return base.FinishedLaunching(app, options);
}
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action completionHandler)
{ FirebasePushNotificationManager.DidReceiveMessage(userInfo);
completionHandler(UIBackgroundFetchResult.NewData);
}