Closed khanhduy62 closed 3 years ago
this.registerNotification(deviceToken)
static async requestNotification(registeredSuccessHandler) { const _onRegistered = (deviceToken) => { this.registerNotification(deviceToken); // registeredSuccessHandler && registeredSuccessHandler(deviceToken); }; const _onRegistrationError = (error) => { console.log('log--_onRegistrationError ', error); }; const _onAzureNotificationHubRegistered = (registrationInfo) => { console.log('log--_onAzureNotificationHubRegistered ', registrationInfo); }; const _onAzureNotificationHubRegistrationError = (error) => { console.log('log--_onAzureNotificationHubRegistrationError ', error); }; const _onRemoteNotification = (remote) => { console.log('log--_onRemoteNotification ', remote); }; const _onLocalNotification = (local) => { Alert.alert( 'Local Notification Received', 'Alert message: ' + local.getMessage(), [ { text: 'Dismiss', onPress: () => {}, }, ], ); }; const callbackPermissions = (permissions) => { try { console.log('log--alert ', permissions?.alert); if (!permissions?.alert) { NotificationHub.requestPermissions() .then(console.log) .catch(console.warn); } } catch (error) {} }; NotificationHub.addEventListener('register', _onRegistered); NotificationHub.addEventListener('registrationError', _onRegistrationError); NotificationHub.addEventListener( 'registerAzureNotificationHub', _onAzureNotificationHubRegistered, ); NotificationHub.addEventListener( 'azureNotificationHubRegistrationError', _onAzureNotificationHubRegistrationError, ); NotificationHub.addEventListener('notification', _onRemoteNotification); NotificationHub.addEventListener('localNotification', _onLocalNotification); NotificationHub.checkPermissions(callbackPermissions); } static registerNotification(deviceToken) { try { NotificationHub.register(deviceToken, { connectionString: AzureHub.connectionString, hubName: AzureHub.hubName, tags: [''] }); } catch (error) { console.log(error); } }
@khanhduy62 did you resolve this?
I did, so I think I should close this topic
@khanhduy62 how did you resolve this? I'm stuck on the same issue.
+1, ping @phongcao
Report
Environment
Issues and Steps to Reproduce
this.registerNotification(deviceToken)
then it's ok.Expected Behavior
Actual Behavior
Link to Code