Configuración para iOS

5.5 Configuración para iOS

Puedes verlo en ente vídeo tutorial o leer las instrucciones más abajo:

https://youtu.be/BoQ8QivsuNU

Para comenzar con la configuración de iOS, asegúrate tener OK estos puntos:

Nota: para que el SDK funcione correctamente el método FinishedLaunching debe ser llamado desde la clase AppDelegate, antes de que se produzca la llamada al método LoadApplication

La clase AppDelegate debería quedar así:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
 Forms.Init();
 DependencyService.Register<Com.Indigitall.Xamarin.iOS.Indigitall>();
 if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
 {
 // iOS 10 or later
 var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge |
UNAuthorizationOptions.Sound;
 UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error)
=>
 {
 if (granted)
 {
 InvokeOnMainThread(() =>
 {
 UIApplication.SharedApplication.RegisterForRemoteNotifications();
 });
 }
 });
 // For iOS 10 display notification (sent via APNS)
 UNUserNotificationCenter.Current.Delegate = new
Com.Indigitall.Xamarin.iOS.UserNotificationCenterDelegate();
 }
 else
 {
 // iOS 9 or before
 var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge |
UIUserNotificationType.Sound;
 var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
 UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
 }
 ...
 UNUserNotificationCenter.Current.Delegate = new
Com.Indigitall.Xamarin.iOS.UserNotificationCenterDelegate();
 ...
 LoadApplication(new App());
 return base.FinishedLaunching(app, options);
}
[Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
override public void RegisteredForRemoteNotifications(UIApplication application, NSData
deviceToken)
{
 IndigitallXamarin.Indigitall.SetDeviceToken(deviceToken, (device) =>
 {
 Console.WriteLine("NewUserRegistered: " + device.DeviceID);
 });
}
[Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]
override public void DidReceiveRemoteNotification(UIApplication application, NSDictionary
userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
 IndigitallXamarin.Indigitall.HandleWithNotification(userInfo, null);
}
[Export("application:handleActionWithIdentifier:forRemoteNotification:withResponseInfo:co
mpletionHandler:")]
override public void HandleAction(UIApplication application, string actionIdentifier,
NSDictionary remoteNotificationInfo, NSDictionary responseInfo, Action completionHandler)
{
 IndigitallXamarin.Indigitall.HandleWithNotification(remoteNotificationInfo,
actionIdentifier);
}
2021-12-15T10:22:24-05:00