Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
345 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In executing the following, how do I get the deviceToken?
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
NSData deviceToken;
// Version check
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// Request notification permissions from the user
// Request authorization and set handler
UNAuthorizationOptions options = 0;
Action<bool, NSError> completionHandler = CompleteAuthorization;
UNUserNotificationCenter.Current.RequestAuthorization(options, completionHandler);
}
UIApplication.SharedApplication.RegisterForRemoteNotifications();
// Watch for notifications while the app is active
UNUserNotificationCenter.Current.Delegate = new UNUserNotificationCenterDelegate();
return base.FinishedLaunching(application, launchOptions);
}
Insert the following code into your AppDelegate class. The first method will be called if the registration is completed. Make sure all the certificates, provisioning and entitlement files are present. The second method will be called if the registration fails. The error parameter will give you a clue as to what is wrong with the registration.
[Foundation.Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
public virtual void RegisteredForRemoteNotifications(UIKit.UIApplication application, NSData deviceToken)
{
}
[Export("application:didFailToRegisterForRemoteNotificationsWithError:")]
public void FailedToRegisterForRemoteNotifications(UIKit.UIApplication application, NSError error)
{
int x = 0;
}