@@ -539,6 +539,7 @@ class myapp extends Component {
539
539
}
540
540
541
541
_onRemoteNotification (notification ) {
542
+ // Note notification will be a JSON string for android
542
543
console .warn (' Notification received: ' + notification);
543
544
}
544
545
` ` `
@@ -550,25 +551,55 @@ const NotificationHub = require('react-native-azurenotificationhub/index.ios');
550
551
551
552
const connectionString = ' ...' ; // The Notification Hub connection string
552
553
const hubName = ' ...' ; // The Notification Hub name
553
- const senderID = ' ...' ; // The Sender ID from the Cloud Messaging tab of the Firebase console
554
554
const tags = [ ... ]; // The set of tags to subscribe to
555
555
556
556
var remoteNotificationsDeviceToken = ' ' ; // The device token registered with APNS
557
557
558
558
class myapp extends Component {
559
559
requestPermissions () {
560
+ // register: Fired when the user registers for remote notifications. The
561
+ // handler will be invoked with a hex string representing the deviceToken.
560
562
NotificationHub .addEventListener (' register' , this ._onRegistered );
563
+
564
+ // registrationError: Fired when the user fails to register for remote
565
+ // notifications. Typically occurs when APNS is having issues, or the device
566
+ // is a simulator. The handler will be invoked with {message: string, code: number, details: any}.
561
567
NotificationHub .addEventListener (' registrationError' , this ._onRegistrationError );
562
- NotificationHub .addEventListener (' registerAzureNotificationHub' , this ._onAzureNotificationHubRegistered );
568
+
569
+ // registerAzureNotificationHub: Fired when registration with azure notification hubs successful
570
+ // with object {success: true}
571
+ NotificationHub .addEventListener (' registerAzureNotificationHub' this ._onAzureNotificationHubRegistered );
572
+
573
+ // azureNotificationHubRegistrationError: Fired when registration with azure notification hubs
574
+ // fails with object {message: string, details: any}
563
575
NotificationHub .addEventListener (' azureNotificationHubRegistrationError' , this ._onAzureNotificationHubRegistrationError );
576
+
577
+ // notification: Fired when a remote notification is received. The
578
+ // handler will be invoked with an instance of `AzureNotificationHubIOS`.
564
579
NotificationHub .addEventListener (' notification' , this ._onRemoteNotification );
580
+
581
+ // localNotification: Fired when a local notification is received. The
582
+ // handler will be invoked with an instance of `AzureNotificationHubIOS`.
565
583
NotificationHub .addEventListener (' localNotification' , this ._onLocalNotification );
566
584
585
+ // Requests notification permissions from iOS, prompting the user's
586
+ // dialog box. By default, it will request all notification permissions, but
587
+ // a subset of these can be requested by passing a map of requested
588
+ // permissions.
589
+ // The following permissions are supported:
590
+ // - `alert`
591
+ // - `badge`
592
+ // - `sound`
593
+ //
594
+ // returns a promise that will resolve when the user accepts,
595
+ // rejects, or if the permissions were previously rejected. The promise
596
+ // resolves to the current state of the permission of
597
+ // {alert: boolean, badge: boolean,sound: boolean }
567
598
NotificationHub .requestPermissions ();
568
599
}
569
600
570
601
register () {
571
- NotificationHub .register (remoteNotificationsDeviceToken, {connectionString, hubName, senderID, tags});
602
+ NotificationHub .register (remoteNotificationsDeviceToken, {connectionString, hubName, tags});
572
603
}
573
604
574
605
unregister () {
@@ -659,6 +690,7 @@ class myapp extends Component {
659
690
}
660
691
661
692
_onLocalNotification (notification ){
693
+ // Note notification will be object for iOS
662
694
AlertIOS .alert (
663
695
' Local Notification Received' ,
664
696
' Alert message: ' + notification .getMessage (),
0 commit comments