public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { if (ApiKeys.AzureServiceBusUrl == nameof(ApiKeys.AzureServiceBusUrl)) { return; } // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl(ApiKeys.AzureServiceBusUrl), ApiKeys.AzureKey); // Register our info with Azure var hub = new SBNotificationHub(cs, ApiKeys.AzureHubName); hub.RegisterNativeAsync(deviceToken, null, err => { if (err != null) { Console.WriteLine("Error: " + err.Description); } else { Console.WriteLine("Success"); } }); }
/// <summary> /// Register a device to the Azure notification hub /// </summary> /// <param name="userGuid">The user guid to associate the registration with</param> public void Register(string userGuid) { //Get token from APN registration process var token = NSUserDefaults.StandardUserDefaults["token"]; var ConnectionString = Constants.ConnectionString; var SharedKey = Constants.SharedKey; var NotificationHubPath = Constants.NotificationHubPath; if (token != null) { var cs = SBConnectionString.CreateListenAccess(new NSUrl(ConnectionString), SharedKey); var hub = new SBNotificationHub(cs, NotificationHubPath); hub.UnregisterAllAsync(token as NSData, (error) => { if (error != null) { return; } var tags = new NSSet(userGuid); var expire = DateTime.Now.AddYears(1).ToString(CultureInfo.CreateSpecificCulture("en-US")); NSError returnError; hub.RegisterTemplate(token as NSData, "Template", "{\"aps\":{\"alert\":\"$(message)\", \"content-available\":\"#(silent)\", \"badge\":\"#(badge)\", \"sound\":\"$(sound)\"}, \"url\":\"$(url)\"}", expire, tags, out returnError); }); } }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl(EnvironmentConstants.AzureListenAccessEndPoint), EnvironmentConstants.AzurePushAccess); // Register our information with Azure var hub = new SBNotificationHub(cs, EnvironmentConstants.AzureNamespace); hub.RegisterNativeAsync(deviceToken, null, err => { if (err != null) { UIAlertViewHelpers.ShowAlert( "Uh Oh!", "There was a problem registering with push notifications. Email [email protected]", "Got it!"); } else { Console.WriteLine("Success"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl("sb://YOUR-SERVICE-NAME-HERE-ns.servicebus.windows.net/"), "YOUR-API-KEY-HERE="); // Register our information with Azure var hub = new SBNotificationHub(cs, "vafiedpushtest"); hub.RegisterNativeAsync(deviceToken, null, err => { if (err != null) { Console.WriteLine("Error: " + err.Description); } else { Console.WriteLine("Success"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { RegisterDeviceWithAppServer(deviceToken); // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess(new NSUrl(ConnectionString), ConnectionStringKey); // Register our info with Azure Hub = new SBNotificationHub(cs, NotificationHub); Hub.RegisterNativeAsync(deviceToken, null, err => { if (err != null) { Console.WriteLine("Error: " + err.Description); } else { Console.WriteLine("Success"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // Connection string from your azure dashboard var cs = SBConnectionString.CreateListenAccess( new NSUrl("sb://" + HUB_NAME + "-ns.servicebus.windows.net/"), HUB_LISTEN_SECRET); // Register our info with Azure var hub = new SBNotificationHub(cs, HUB_NAME); hub.RegisterNative(deviceToken, null, err => { if (err != null) { Console.WriteLine("Error: " + err.Description); homeViewController.RegisteredForNotifications("Error: " + err.Description); } else { Console.WriteLine("Success"); homeViewController.RegisteredForNotifications("Successfully registered for notifications"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { var connectionString = SBConnectionString.CreateUsingSharedAccessSecretWithListenAccess( new NSUrl(@"sb://" + hubNamespace + ".servicebus.windows.net"), key); this._hub = new SBNotificationHub(connectionString, hubName); _hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); } else { NSSet tags = null; // create tags if you want _hub.RegisterTemplateAsync(deviceToken, "App2000iOSRegistration", @"{""aps"": {""alert"": ""$(msg)""}}", @"$(expiryProperty)", tags, (registrationError) => { if (registrationError != null) { Console.WriteLine("Error calling RegisterTemplate: {0}", registrationError.ToString()); } }); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { var connectionString = SBConnectionString.CreateListenAccess(new NSUrl(Constants.NotificationHubUrl), Constants.NotificationHubKey); var hub = new SBNotificationHub(connectionString, Constants.NotificationHubName); hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; // create tags if you want hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }