В настоящее время я работаю над push-уведомлением xosmarin form ios app. если приложение закрыто (перевернуто), то DidReceiveRemoteNotification не вызывает.
полезная нагрузка данных такая же, как на стороне сервера ,
private void SendMessage (строка [] MessageTokenArray, строка 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);
}
}
в xamarin ios
public override bool FinishedLaunching (приложение UIApplication, параметры NSDictionary)
{
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, NSDictionary userInfo, Action завершениеHandler)
{
FirebasePushNotificationManager.DidReceiveMessage (UserInfo);
completionHandler (UIBackgroundFetchResult.NewData);
}