Xamarin iOS SDK
Исходный код модуля
Скачать пример
Чтобы интегрировать Wavesend в ваше приложение Xamarin iOS:
1. Добавьте nuget-пакет Wavesend.Xamarin.iOS в ваше решение.
2. В вашем проекте откройте AppDelegate.cs и подключите Wavesend, добавив строку using Wavesend.
3. В файле Info.plist добавьте ключ Wavesend_APPID со строковым значением вашего Wavesend Application ID.
4. Организуйте следующие импорты:
- using Wavesend;
- using UserNotifications;
5. Добавьте следующие методы в класс AppDelegate:
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken){ PushNotificationManager.PushManager.HandlePushRegistration (deviceToken);}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error){ PushNotificationManager.PushManager.HandlePushRegistrationFailure (error);}
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo){ PushNotificationManager.PushManager.HandlePushReceived (userInfo);}6. Добавьте приведённый ниже код в метод public override bool FinishedLaunching(UIApplication app, NSDictionary launchOptions):
PushNotificationManager pushmanager = PushNotificationManager.PushManager;pushmanager.Delegate = new PushDelegate();UNUserNotificationCenter.Current.Delegate = pushmanager.notificationCenterDelegate;
if (options != null) { if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) { pushmanager.HandlePushReceived(options); }}
pushmanager.RegisterForPushNotifications();7. Добавьте следующий класс в AppDelegate:
public class PushDelegate : PushNotificationDelegate { public override void OnPushAccepted(PushNotificationManager pushManager, NSDictionary pushNotification) { Console.WriteLine("Push accepted: " + pushNotification); }
public override void OnPushReceived(PushNotificationManager pushManager, NSDictionary pushNotification, bool onStart) { Console.WriteLine("Push received: " + pushNotification); }
public override void OnDidRegisterForRemoteNotificationsWithDeviceToken(NSString token) { Console.WriteLine("Registered for push notifications: " + token); }
public override void OnDidFailToRegisterForRemoteNotificationsWithError(NSError error) { Console.WriteLine("Error: " + error); } }Поделитесь с нами своим мнением
Section titled “Поделитесь с нами своим мнением”Ваши отзывы помогают нам улучшать наш продукт, поэтому мы будем рады, если вы расскажете нам о любых проблемах, возникших в процессе интеграции SDK. Если вы столкнетесь с какими-либо трудностями, пожалуйста, поделитесь своими мыслями с нами через эту форму.