Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Sometimes the push callback is received shortly before the app is fully active in the foreground.
// In this case you'll want to save off the notification info and wait until the app is fully shown
// in the foreground before displaying any UI. You could use AppState.addEventListener to be notified
// when the app is fully in the foreground.
// Showing an alert when not in the "active" state seems to work on iOS; for Android, we show a toast
// message instead
if (Platform.OS === 'android') {
ToastAndroid.show(`Notification while inactive:\n${message}`, ToastAndroid.LONG);
}
Alert.alert(title, message);
}
}
});
Crashes.setListener({
shouldProcess(report) {
console.log(`Should process report with id: ${report.id}'`);
return true;
},
shouldAwaitUserConfirmation() {
console.log('Should await user confirmation');
Alert.alert(
'One or more crashes were detected, do you want to report them?',
null,
[
{ text: 'Yes, and ask me again if it occurs again.', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.SEND) },
{ text: 'Yes, always send them', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.ALWAYS_SEND) },
{ text: 'Don\'t send at this time', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.DONT_SEND) },
]
);
// when the app is fully in the foreground.
// Showing an alert when not in the "active" state seems to work on iOS; for Android, we show a toast
// message instead
if (Platform.OS === "android") {
ToastAndroid.show(
`Notification while inactive:\n${message}`,
ToastAndroid.LONG
);
}
Alert.alert(title, message);
}
}
});
Crashes.setListener({
shouldProcess(report) {
console.log(`Should process report with id: ${report.id}'`);
return true;
},
shouldAwaitUserConfirmation() {
console.log("Should await user confirmation");
Alert.alert(
"One or more crashes were detected, do you want to report them?",
undefined,
[
{
text: "Yes, and ask me again if it occurs again.",
onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.SEND)
},
{
// message instead
if (Platform.OS === 'android') {
ToastAndroid.show(`Notification while inactive:\n${message}`, ToastAndroid.LONG);
}
Alert.alert(title, message);
}
}
});
Data.setListener({
onRemoteOperationCompleted(document) {
console.log(`onRemoteOperationCompleted called in the delegate method. document id: ${document.id}`);
}
});
Crashes.setListener({
shouldProcess(report) {
console.log(`Should process report with id: ${report.id}'`);
return true;
},
shouldAwaitUserConfirmation() {
console.log('Should await user confirmation');
Alert.alert(
'One or more crashes were detected, do you want to report them?',
null,
[
{ text: 'Yes, and ask me again if it occurs again.', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.SEND) },
{ text: 'Yes, always send them', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.ALWAYS_SEND) },
{ text: 'Don\'t send at this time', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.DONT_SEND) },
]
);
// Sometimes the push callback is received shortly before the app is fully active in the foreground.
// In this case you'll want to save off the notification info and wait until the app is fully shown
// in the foreground before displaying any UI. You could use AppState.addEventListener to be notified
// when the app is fully in the foreground.
// Showing an alert when not in the "active" state seems to work on iOS; for Android, we show a toast
// message instead
if (Platform.OS === 'android') {
ToastAndroid.show(`Notification while inactive:\n${message}`, ToastAndroid.LONG);
}
Alert.alert(title, message);
}
}
});
Crashes.setListener({
shouldProcess(report) {
console.log(`Should process report with id: ${report.id}'`);
return true;
},
shouldAwaitUserConfirmation() {
console.log('Should await user confirmation');
Alert.alert(
'One or more crashes were detected, do you want to report them?',
null,
[
{ text: 'Yes, and ask me again if it occurs again.', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.SEND) },
{ text: 'Yes, always send them', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.ALWAYS_SEND) },
{ text: 'Don\'t send at this time', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.DONT_SEND) },
]
);
// message instead
if (Platform.OS === 'android') {
ToastAndroid.show(`Notification while inactive:\n${message}`, ToastAndroid.LONG);
}
Alert.alert(title, message);
}
}
});
Data.setRemoteOperationListener({
onRemoteOperationCompleted(document) {
console.log(`onRemoteOperationCompleted called in the delegate method. document id: ${document.id}`);
}
});
Crashes.setListener({
shouldProcess(report) {
console.log(`Should process report with id: ${report.id}'`);
return true;
},
shouldAwaitUserConfirmation() {
console.log('Should await user confirmation');
Alert.alert(
'One or more crashes were detected, do you want to report them?',
null,
[
{ text: 'Yes, and ask me again if it occurs again.', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.SEND) },
{ text: 'Yes, always send them', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.ALWAYS_SEND) },
{ text: 'Don\'t send at this time', onPress: () => Crashes.notifyUserConfirmation(UserConfirmation.DONT_SEND) },
]
);