You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/Demo/Demo.iOS/AppDelegate.cs

48 lines
1.9 KiB

using Foundation;
using LibVLCSharp.Forms.Shared;
using UIKit;
using UserNotifications;
using Xamarin.Forms;
[assembly: ExportRenderer(typeof(WebView), typeof(Xamarin.Forms.Platform.iOS.WkWebViewRenderer))]
namespace Demo.iOS
{
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
this.Notification();
LibVLCSharpFormsRenderer.Init();
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
CameraPreview.iOS.CameraPreviewSettings.Instance.Init(new IosDecoder());
return base.FinishedLaunching(app, options);
}
public void Notification()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// Ask the user for permission to get notifications on iOS 10.0+
UNUserNotificationCenter.Current.RequestAuthorization(
UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
(approved, error) => { });
// Watch for notifications while app is active
UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
}
else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
// Ask the user for permission to get notifications on iOS 8.0+
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
}
}
}
}