-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAppDelegate.cs
76 lines (66 loc) · 3.14 KB
/
AppDelegate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ==========================================================================
// Notifo.io
// ==========================================================================
// Copyright (c) Sebastian Stehle
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Foundation;
using Notifo.SDK;
using Notifo.SDK.FirebasePlugin;
using Prism;
using Prism.Ioc;
using Sample.iOS.Shared;
using UIKit;
using UserNotifications;
#pragma warning disable SA1300 // Element should begin with upper-case letter
namespace Sample.iOS
#pragma warning restore SA1300 // Element should begin with upper-case letter
{
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate, IUNUserNotificationCenterDelegate
{
public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App(new iOSInitializer()));
NotifoIO.Current
.SetNotificationHandler(new NotificationHandler())
.UseDefaults()
.UseFirebasePluginEventsProvider(launchOptions, true);
UNUserNotificationCenter.Current.Delegate = this;
return base.FinishedLaunching(uiApplication, launchOptions);
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
NotifoIO.Current.DidRegisterRemoteNotifications(deviceToken);
}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
NotifoIO.Current.RemoteNotificationRegistrationFailed(error);
}
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
public override async void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
{
NotifoIO.Current.DidReceiveMessageAsync(userInfo);
completionHandler(UIBackgroundFetchResult.NewData);
}
[Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")]
public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
{
NotifoIO.Current.DidReceiveNotificationResponse(center, response, completionHandler);
}
#pragma warning disable SA1300 // Element should begin with upper-case letter
#pragma warning disable IDE1006 // Naming Styles
public class iOSInitializer : IPlatformInitializer
#pragma warning restore IDE1006 // Naming Styles
#pragma warning restore SA1300 // Element should begin with upper-case letter
{
public void RegisterTypes(IContainerRegistry containerRegistry)
{
// Register any platform specific implementations
}
}
}
}