Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { AppRegistry,AppState,Alert } from 'react-native';
import App from './App';
import Push from 'appcenter-push';
AppRegistry.registerComponent('goforeat_app', () => App);
Push.setListener({
onPushNotificationReceived: pushNotification => {
console.log(112312321321312321);
let message = pushNotification.message;
let title = pushNotification.title;
let customProperties = [];
let timestamp = Date.now();
// Custom name/value pairs set in the App Center web portal are in customProperties
if (
pushNotification.customProperties &&
Object.keys(pushNotification.customProperties).length > 0
) {
customProperties = pushNotification.customProperties;
}
Alert.alert(title, message);
return (
);
}
}
Push.setListener({
onPushNotificationReceived(pushNotification) {
let message = pushNotification.message;
let title = pushNotification.title;
if (message === null || message === undefined) {
// Android messages received in the background don't include a message. On Android, that fact can be used to
// check if the message was received in the background or foreground. For iOS the message is always present.
title = 'Android background';
message = '';
}
// Any custom name/value pairs added in the portal are in customProperties
if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
message += `\nCustom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
}
AppCenter: AppCenterScreen,
Analytics: AnalyticsScreen,
Transmission: TransmissionScreen,
Crashes: CrashesScreen
},
{
tabBarOptions: {
activeBackgroundColor: 'white',
inactiveBackgroundColor: 'white',
},
}
);
export default createAppContainer(TabNavigator);
Push.setListener({
onPushNotificationReceived(pushNotification) {
let message = pushNotification.message;
const title = pushNotification.title;
// Message can be null on iOS silent push or Android background notifications.
if (message === null) {
message = '';
} else {
message += '\n';
}
// Any custom name/value pairs added in the portal are in customProperties
if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
message += `Custom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
}
const { navigate } = this.props.navigation;
return (
Analytics: AnalyticsScreen,
Transmission: TransmissionScreen,
Crashes: CrashesScreen,
Data: DataScreen
},
{
tabBarOptions: {
activeBackgroundColor: 'white',
inactiveBackgroundColor: 'white',
},
}
);
export default createAppContainer(TabNavigator);
Push.setListener({
onPushNotificationReceived(pushNotification) {
let message = pushNotification.message;
const title = pushNotification.title;
// Message can be null on iOS silent push or Android background notifications.
if (message === null) {
message = '';
} else {
message += '\n';
}
// Any custom name/value pairs added in the portal are in customProperties
if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
message += `Custom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
}
<button title="Test Crashes"> navigate("Crashes")} />
</button><button title="Test Analytics"> navigate("Analytics")} />
</button><button title="Test Push"> navigate("Push")} />
</button><button title="Test Other AppCenter APIs"> navigate("AppCenter")}
/>
);
}
}
Push.setListener({
onPushNotificationReceived(pushNotification) {
let message = pushNotification.message;
let title = pushNotification.title;
if (title === null) {
title = "";
}
if (message === null) {
message = "";
} else {
message += "\n";
}
// Any custom name/value pairs added in the portal are in customProperties
if (
pushNotification.customProperties &&</button>
async refreshUI() {
const appCenterEnabled = await AppCenter.isEnabled();
this.setState({ appCenterEnabled });
const authEnabled = await Auth.isEnabled();
this.setState({ authEnabled });
const pushEnabled = await Push.isEnabled();
this.setState({ pushEnabled });
const installId = await AppCenter.getInstallId();
this.setState({ installId });
}
async refreshUI() {
const appCenterEnabled = await AppCenter.isEnabled();
this.setState({ appCenterEnabled });
const authEnabled = await Auth.isEnabled();
this.setState({ authEnabled });
const pushEnabled = await Push.isEnabled();
this.setState({ pushEnabled });
const installId = await AppCenter.getInstallId();
this.setState({ installId });
}
async componentDidMount() {
const component = this;
const pushEnabled = await Push.isEnabled();
component.setState({ pushEnabled });
}