I've tried everything to get push notifications for Android to work with Pinpoint in my react native app.
The iOS integration works as expected.
In android, i'm able to record the endpoint, but when I export the endpoint from pinpoint, I can see that the field that controls push notification--OptOut--is set to ALL
.
This is the integration that I have in my App.js to record the endpoints:
import React, {Component} from 'react';
import { StyleSheet, View, PushNotificationIOS, AsyncStorage, Text } from 'react-native'
//aws
import Amplify, { Auth } from 'aws-amplify'
import aws_exports from './aws-exports'
import PushNotification from '@aws-amplify/pushnotification'
Analytics.configure(aws_exports);
Amplify.configure(aws_exports)
console.log('exports',aws_exports)
PushNotification.configure(aws_exports);
type Props = {};
class App extends Component<Props> {
componentDidMount(){
console.log(PushNotification)
// get the notification data when notification is received
PushNotification.onNotification((notification) => {
// Note that the notification object structure is different from Android and IOS
console.log('in app notification', notification);
// required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
notification.finish(PushNotificationIOS.FetchResult.NoData);
});
// get the registration token
// This will only be triggered when the token is generated or updated.
PushNotification.onRegister((token) => {
console.log('in app registration', token);
});
}
render() {
...
}
}
export default codePush(codePushOptions)(App)