public static void Initialize(string notificationHubConnectionString, string notificationHubPath, NSDictionary options, bool autoRegistration = true, bool enableDelayedResponse = true) { Hub = new SBNotificationHub(notificationHubConnectionString, notificationHubPath); TokenKey = new NSString($"{notificationHubPath}_Token"); PushRegisteredKey = $"{notificationHubPath}_PushRegistered"; CrossAzurePushNotification.Current.NotificationHandler = CrossAzurePushNotification.Current.NotificationHandler ?? new DefaultPushNotificationHandler(); if (options?.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey) ?? false) { var pushPayload = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary; if (pushPayload != null) { var parameters = GetParameters(pushPayload); var notificationResponse = new NotificationResponse(parameters, string.Empty, NotificationCategoryType.Default); if (_onNotificationOpened == null && enableDelayedResponse) { delayedNotificationResponse = notificationResponse; } else { _onNotificationOpened?.Invoke(CrossAzurePushNotification.Current, new AzurePushNotificationResponseEventArgs(notificationResponse.Data, notificationResponse.Identifier, notificationResponse.Type)); } CrossAzurePushNotification.Current.NotificationHandler?.OnOpened(notificationResponse); } } if (autoRegistration) { CrossAzurePushNotification.Current.RegisterForPushNotifications(); } }
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"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(App.ListenConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } // create tags if you want // Refer to : https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-routing-tag-expressions/ NSSet tags = null; Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public void Registed(object sender, RegistedEventArgs e) { hub = new SBNotificationHub(ConfigurationSettings.HUB_CONNEXTION_STRING, ConfigurationSettings.HUB_NAME); hub.UnregisterAllAsync(e.DeviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(userMarks); // create tags if you want hub.RegisterNative(e.DeviceToken, tags, out NSError regError); if (regError == null) { isRegisted = true; } else { isRegisted = false; } }); AppDelegate.Registed -= Registed; }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(PushNotificationConstants.HUB_CONNECTION_STRING, PushNotificationConstants.HUB_NAME); string normalizedDeviceToken = deviceToken.Description .Replace(" ", string.Empty) .Replace("<", string.Empty) .Replace(">", string.Empty).ToUpper(); System.Diagnostics.Debug.WriteLine($"******************************************"); System.Diagnostics.Debug.WriteLine($"Device Token: {normalizedDeviceToken}"); System.Diagnostics.Debug.WriteLine($"******************************************"); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { System.Diagnostics.Debug.WriteLine(new AggregateException("Erro ao registrar NotificationHub", new NSErrorException(error))); return; } NSSet tags = null; Hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { System.Diagnostics.Debug.WriteLine(new AggregateException("Error at registering native hub", new NSErrorException(errorCallback))); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ListenConnectionString, Constants.NotificationHubName); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } Preferences.Set("appToken", deviceToken.ToString()); string[] myTags = new[] { Preferences.Get("appTags", string.Empty) }; if (myTags.Length == 0) { myTags = new string[] { "0,1,2,3,4,5" } } ; //NSSet tags = null; // create tags if you want //NSSet tags = new NSSet(new string[] { "0,", "1,", "2,", "3,", "4,", "5" }); NSSet tags = new NSSet(myTags); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { //LNBFans.Helpers.SettingHelper.CreateTagFile(); Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { //JPUSHService.RegisterDeviceToken(deviceToken); try { _deviceToken = deviceToken; Hub = new SBNotificationHub(ConnectionString, NotificationHubPath); 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()); } }); }); } catch (Exception ex) { Console.WriteLine("RegisterNativeAsync exception:" + ex.Message.ToString()); } }
public void RegisteredForRemoteNotifications(NSData deviceToken) { Console.WriteLine("deviceToken: " + deviceToken); Hub = new SBNotificationHub(PushNotificationCredentials.AzureListenConnectionString, PushNotificationCredentials.AzureNotificationHubName); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(PushNotificationCredentials.Tags); Hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { var tagArray = ProducerClient.Shared.UserRole.GetTagArray(); var notificationHub = new SBNotificationHub(Settings.NotificationsConnectionString, Settings.NotificationsName); Log.Debug($"Registering with Azure Notification Hub '{Settings.NotificationsName}' with Tags ({string.Join (ConstantStrings.Comma, tagArray)})"); var tags = new NSSet(tagArray); var expire = DateTime.Now.AddDays(90).ToString(CultureInfo.CreateSpecificCulture("en-US")); notificationHub.RegisterTemplateAsync(deviceToken, nameof(PushTemplate), PushTemplate.iOS, expire, tags, err => { if (err != null) { Log.Error($"{err.Description}"); } else { var token = deviceToken.ToString().Replace(" ", string.Empty).Trim('<', '>'); Log.Debug($"Successfully Registered for Notifications. (device token: {token})"); } }); }
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 application, NSData deviceToken) { try { var connectionString = Settings.NotificationConnectionString; var hubPath = Settings.NotificationHubPath; _hub = new SBNotificationHub(connectionString, hubPath); _hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Debug.WriteLine($"Error calling Unregister: {0}", error.ToString()); return; } var tags = new NSSet(Settings.UserId.ToString()); // create tags if you want _hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Debug.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); Debug.WriteLine($"RegisteredForRemoteNotifications, DeviceToken = {deviceToken}"); } catch (Exception ex) { Mvx.Resolve <IExceptionService>().HandleException(ex); } }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // Create a new notification hub with the connection string and hub path _hub = new SBNotificationHub(ConnectionString, NotificationHubPath); // Unregister any previous instances using the device token _hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { // Error unregistering Console.WriteLine($"Error: {error.Description}"); return; } // Register this device with the notification hub _hub.RegisterNativeAsync(deviceToken, null, (registerError) => { if (registerError != null) { // Error registering Console.WriteLine($"Error: {error.Description}"); } }); }); }
/// <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 application, NSData deviceToken) { Hub = new SBNotificationHub(AppConstants.ListenConnectionString, AppConstants.NotificationHubName); // update registration with Azure Notification Hub Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Debug.WriteLine($"Unable to call unregister {error}"); return; } var tags = new NSSet(AppConstants.SubscriptionTags.ToArray()); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Debug.WriteLine($"RegisterNativeAsync error: {errorCallback}"); } }); var templateExpiration = DateTime.Now.AddDays(120).ToString(System.Globalization.CultureInfo.CreateSpecificCulture("en-US")); Hub.RegisterTemplateAsync(deviceToken, "defaultTemplate", AppConstants.APNTemplateBody, templateExpiration, tags, (errorCallback) => { if (errorCallback != null) { if (errorCallback != null) { Debug.WriteLine($"RegisterTemplateAsync error: {errorCallback}"); } } }); }); }
public void RegisteredForRemoteNotifications(NSData deviceToken) { Hub = new SBNotificationHub(PushNotificationCredentials.AzureListenConnectionString, PushNotificationCredentials.AzureNotificationHubName); Hub.UnregisterAllAsync(deviceToken, error => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(PushNotificationCredentials.Tags); Hub.RegisterNativeAsync(deviceToken, tags, errorCallback => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); // Register for Notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes( UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ListenConnectionString, Constants.NotificationHubName); List <string> tagList = new List <string>(); //add global identifier tagList.Add("buyplane"); if (Settings.IsRegistered) { tagList.Add("userid:" + Settings.UserID.ToString()); } Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { System.Diagnostics.Debug.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(tagList.ToArray()); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { System.Diagnostics.Debug.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { var hubName = String.Empty; var hubConnectionString = String.Empty; #if DEBUG hubName = Settings.AzureNotificationHubNameSandbox; hubConnectionString = Settings.AzureNotificationHubConnectionStringSandbox; #else hubName = Settings.AzureNotificationHubNameProd; hubConnectionString = Settings.AzureNotificationHubConnectionStringProd; #endif _Hub = new SBNotificationHub(hubConnectionString, hubName); _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()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { string originalDeviceToken = deviceToken.ToString(); DEVICE_TOKEN = originalDeviceToken.Trim('<').Trim('>').Replace(" ", ""); BaseSingleton <GlobalSetting> .Instance.MessagingDeviceToken = DEVICE_TOKEN; MessagingCenter.Send <object>(this, "device_token"); // Create a new notification hub with the connection string and hub path Hub = new SBNotificationHub(ConnectionString, NotificationHubPath); // Unregister any previous instances using the device token Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { // Error unregistering return; } // Register this device with the notification hub Hub.RegisterNativeAsync(deviceToken, null, (registerError) => { if (registerError != null) { // Error registering } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } var tags_list = new List <string>() { }; var mainviewModel = MainViewModel.GetInstance(); if (mainviewModel.Employee != null) { var userId = mainviewModel.Employee.EmployeeId; tags_list.Add("userId:" + userId); } var tags = new NSSet(tags_list.ToArray()); Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(AppConfigurations.NotificationHubConnectionString, AppConfigurations.NotificationHubName); Hub.UnregisterAllAsync(deviceToken); Hub.UnregisterAll(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } List <string> tags = new List <string>(); tags.Add(AppConfigurations.Environment); if (ServiceLocator.Current.GetInstance <ILoginViewModel>() != null && ServiceLocator.Current.GetInstance <ILoginViewModel>().User != null) { tags.Add(ServiceLocator.Current.GetInstance <ILoginViewModel>().User.UserName); } Hub.RegisterNative(deviceToken, new NSSet(tags.ToArray()), (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public void RegisterNotificationHub() { if (CoreSettings.DeviceToken == null) { "Push notification token has not been set".ConsoleWrite("Missing Token", true); return; } var registrationId = CoreSettings.DeviceToken; if (AzureNotificationHub.HUB == null) { AzureNotificationHub.HUB = new SBNotificationHub(CoreSettings.Config.AzureSettings.AzureListenConnection, CoreSettings.Config.AzureSettings.AzureHubName); } AzureNotificationHub.HUB.UnregisterAllAsync(registrationId, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = new NSSet(CoreSettings.NotificationTags.ToArray()); AzureNotificationHub.HUB.RegisterNativeAsync(registrationId, tags, (errorCallback) => { if (errorCallback != null) { Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public void RegisterForRemoteHubNotifications(string notificationHubName, string connectionString, string channelName, string[] tags) { Hub = new SBNotificationHub(connectionString, notificationHubName); Hub.UnregisterAllAsync(DeviceToken, (error) => { if (error != null) { if (this.NotificationError != null) { this.NotificationError(this, new AzureNotificationErrorEventArgs("Error calling Unregister: " + error.ToString())); } return; } //// NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(DeviceToken, new NSSet(tags), (errorCallback) => { if (errorCallback != null) { if (this.NotificationError != null) { this.NotificationError(this, new AzureNotificationErrorEventArgs("RegisterNativeAsync error: " + errorCallback.ToString())); } Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(AzurePushConstants.ListenConnectionString, AzurePushConstants.NotificationHubName); Hub.UnregisterAll(deviceToken, async(error) => { if (error != null) { System.Diagnostics.Debug.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } var userService = Mvx.IoCProvider.Resolve <IUserService>(); var user = await userService.GetLoggedInUser(); if (user != null) { NSSet tags = new NSSet(new string[] { "username:"******"RegisterNativeAsync error: " + errorCallback.ToString()); } }); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // Modify device token for compatibility Azure var token = deviceToken.Description; token = token.Trim('<', '>').Replace(" ", ""); // You need the Settings plugin for this! Settings.DeviceToken = token; // TODO add your own access key var hub = new SBNotificationHub("Endpoint=sb://xamarinnotifications-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=<your key here>", "xamarinnotifications"); NSSet tags = null; // create tags if you want hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { var alert = new UIAlertView("ERROR!", errorCallback.ToString(), null, "OK", null); alert.Show(); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { _notificationHub = new SBNotificationHub(KHubConnectionString, KHubnameString); _notificationHub.RegisterNativeAsync(deviceToken, null, (NSError error) => { }); }
private async void Navigation() { TokenRegistration token = new TokenRegistration(); iniciarSesionButton.Enabled = false; AfiliadosSeguroPopular afiliado = new AfiliadosSeguroPopular(); var afiliadoSP = await afiliado.GetDataFromAPi(polizaTextField.Text, numeroConsecutivoTextField.Text); if (afiliadoSP.folio != null) { ConfiguracionApp config = new ConfiguracionApp(); config.GuardarConfiguracion(afiliadoSP); var plist = NSUserDefaults.StandardUserDefaults; try { Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(token.Token, (error) => { if (error != null) { return; } NSSet tags = new NSSet(plist.StringForKey("userFolio"), plist.StringForKey("userTag")); // create tags if you want Hub.RegisterNativeAsync(token.Token, tags, (errorCallback) => { if (errorCallback != null) { } }); }); } catch (Exception ex) { } this.PerformSegue("loginUserSeguroPopular", this); } else { iniciarSesionButton.Enabled = true; UIAlertView alert = new UIAlertView() { Message = "Usted no esta afiliado en nuestro sistema.", Title = "Seguro Popular Hidalgo" }; alert.AddButton("Ok"); alert.Show(); } }
public static async Task Initialize(string notificationHubConnectionString, string notificationHubPath, NSDictionary options, bool autoRegistration = true) { Hub = new SBNotificationHub(notificationHubConnectionString, notificationHubPath); CrossAzurePushNotification.Current.NotificationHandler = CrossAzurePushNotification.Current.NotificationHandler ?? new DefaultPushNotificationHandler(); if (autoRegistration) { await CrossAzurePushNotification.Current.RegisterForPushNotifications(); } }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { _hub = new SBNotificationHub(KConnectionString, KHubString); _hub.RegisterNativeAsync(deviceToken, null, (NSError error) => { if (error != null) { Console.WriteLine(error.Description); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { this.Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHub); this.Hub.RegisterNativeAsync(deviceToken, null, (error) => { if (error != null) { Console.WriteLine("Registration Failed"); } }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { // デバイスIDを記憶する byte[] result = new byte[deviceToken.Length]; Marshal.Copy(deviceToken.Bytes, result, 0, (int)deviceToken.Length); var deviceTokenEncoding = BitConverter.ToString(result).Replace("-", ""); // デバイスIDを記憶する (App.Current as App).DeviceId = deviceTokenEncoding; Hub = new SBNotificationHub(Constant.ListenConnectionString, Constant.NotificationHubName); // update registration with Azure Notification Hub Hub.UnregisterAll(deviceToken, (error) => { if (error != null) { Analytics.TrackEvent("Unable to call unregister", new Dictionary <string, string> { { nameof(error), error.ToString() } }); return; } var tags = new NSSet(Constant.SubscriptionTags.ToArray()); Hub.RegisterNative(deviceToken, tags, (errorCallback) => { if (errorCallback != null) { Analytics.TrackEvent("RegisterNativeAsync", new Dictionary <string, string> { { nameof(errorCallback), errorCallback.ToString() } }); } }); var templateExpiration = DateTime.Now.AddDays(120).ToString(System.Globalization.CultureInfo.CreateSpecificCulture("en-US")); Hub.RegisterTemplate(deviceToken, "defaultTemplate", Constant.APNTemplateBody, templateExpiration, tags, (errorCallback) => { if (errorCallback != null) { if (errorCallback != null) { Analytics.TrackEvent("RegisterTemplateAsync", new Dictionary <string, string> { { nameof(errorCallback), errorCallback.ToString() } }); } } }); }); }
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.RegisterNativeAsync (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) { Hub = new SBNotificationHub(Core.Constants.ConnectionString, Core.Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Debug.WriteLine("Error calling Unregister: {0}", error.ToString()); return; } NSSet tags = null; Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => { if (errorCallback != null) Debug.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); }); }); }
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 application, NSData deviceToken) { // NOTE: Don't call the base implementation on a Model class // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath); 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()); }); }); }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(ConnectionString, NotificationHubPath); App.StoredNotificationToken.DeviceToken = deviceToken.ToString(); }
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken) { if (deviceToken != null) { Hub = new SBNotificationHub (Constants.ConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync (deviceToken, (error) => { if (error != null) { Console.WriteLine ("Error calling Unregister: {0}", error.ToString ()); return; } NSSet tags = null; var settingsService = ServiceLocator.Current.GetInstance<ISettingsService> (); if (!string.IsNullOrWhiteSpace (settingsService.EmailAddress)) { tags = new NSSet (new string[] { "platform:iOS", "emailAddress:" + settingsService.EmailAddress }); } else { tags = new NSSet (new string[] { "platform:iOS" }); } Hub.RegisterNativeAsync (deviceToken, tags, (errorCallback) => { if (errorCallback != null) Console.WriteLine ("RegisterNativeAsync error: " + errorCallback.ToString ()); }); }); } }
public void RegisterForRemoteHubNotifications(string notificationHubName, string connectionString, string channelName, string[] tags) { Hub = new SBNotificationHub(connectionString, notificationHubName); Hub.UnregisterAllAsync(DeviceToken, (error) => { if (error != null) { if (this.NotificationError != null) this.NotificationError(this, new AzureNotificationErrorEventArgs("Error calling Unregister: " + error.ToString())); return; } //// NSSet tags = null; // create tags if you want Hub.RegisterNativeAsync(DeviceToken, new NSSet(tags), (errorCallback) => { if (errorCallback != null) { if (this.NotificationError != null) this.NotificationError(this, new AzureNotificationErrorEventArgs("RegisterNativeAsync error: " + errorCallback.ToString())); Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString()); } }); }); }
public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) { #if ENABLE_TEST_CLOUD #else 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"); }); #endif }