How to use appcenter-crashes - 10 common examples

To help you get started, we’ve selected a few appcenter-crashes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / appcenter-sdk-react-native / TestApp34 / MainScreen.js View on Github external
// 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) },
      ]
    );
github microsoft / appcenter-sdk-react-native / TestAppTypescript / src / MainScreen.tsx View on Github external
// 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)
        },
        {
github microsoft / appcenter-sdk-react-native / TestApp / app / App.js View on Github external
// 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) },
      ]
    );
github microsoft / appcenter-sdk-react-native / DemoApp / MainScreen.js View on Github external
// 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) },
      ]
    );
github microsoft / appcenter-sdk-react-native / DemoApp / app / App.js View on Github external
// 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) },
      ]
    );
github microsoft / appcenter-sdk-react-native / DemoApp / app / screens / CrashesScreen.js View on Github external
async nativeCrash() {
    // In Android debug or non app store environment for iOS.
    await Crashes.generateTestCrash();

    // If the SDK disabled the test crash, use this one.
    await NativeModules.DemoAppNative.generateTestCrash();
  }
github microsoft / appcenter-sdk-react-native / TestApp / app / screens / CrashesScreen.js View on Github external
async nativeCrash() {
    // In Android debug or non app store environment for iOS.
    await Crashes.generateTestCrash();

    // If the SDK disabled the test crash, use this one.
    await NativeModules.TestAppNative.generateTestCrash();
  }
github microsoft / appcenter-sdk-react-native / TestApp / app / screens / CrashesScreen.js View on Github external
async componentDidMount() {
    await this.refreshToggle();

    const crashedInLastSession = await Crashes.hasCrashedInLastSession();
    const lastSessionStatus = crashedInLastSession ? 'Crashed' : 'OK';
    this.setState({ lastSessionStatus });

    if (crashedInLastSession) {
      const crashReport = await Crashes.lastSessionCrashReport();
      const crashReportString = JSON.stringify(crashReport, null, 4);
      console.log('App crashed in the last session. Crashes.lastSessionCrashReport(): ', crashReportString);
    }

    const hasReceivedMemoryWarning = await Crashes.hasReceivedMemoryWarningInLastSession();
    const memoryWarning = hasReceivedMemoryWarning ? 'Received' : 'No';
    this.setState({ memoryWarning });

    const textAttachment = await AttachmentsProvider.getTextAttachment();
    this.setState({ textAttachment });
github microsoft / appcenter-sdk-react-native / DemoApp / app / screens / CrashesScreen.js View on Github external
async componentDidMount() {
    await this.refreshToggle();

    const crashedInLastSession = await Crashes.hasCrashedInLastSession();
    const lastSessionStatus = crashedInLastSession ? 'Crashed' : 'OK';
    this.setState({ lastSessionStatus });

    if (crashedInLastSession) {
      const crashReport = await Crashes.lastSessionCrashReport();
      const crashReportString = JSON.stringify(crashReport, null, 4);
      console.log('App crashed in the last session. Crashes.lastSessionCrashReport(): ', crashReportString);
    }

    const hasReceivedMemoryWarning = await Crashes.hasReceivedMemoryWarningInLastSession();
    const memoryWarning = hasReceivedMemoryWarning ? 'Received' : 'No';
    this.setState({ memoryWarning });

    const textAttachment = await AttachmentsProvider.getTextAttachment();
    this.setState({ textAttachment });
github microsoft / appcenter-sdk-react-native / DemoApp / app / screens / CrashesScreen.js View on Github external
async componentDidMount() {
    await this.refreshToggle();

    const crashedInLastSession = await Crashes.hasCrashedInLastSession();
    const lastSessionStatus = crashedInLastSession ? 'Crashed' : 'OK';
    this.setState({ lastSessionStatus });

    if (crashedInLastSession) {
      const crashReport = await Crashes.lastSessionCrashReport();
      const crashReportString = JSON.stringify(crashReport, null, 4);
      console.log('App crashed in the last session. Crashes.lastSessionCrashReport(): ', crashReportString);
    }

    const hasReceivedMemoryWarning = await Crashes.hasReceivedMemoryWarningInLastSession();
    const memoryWarning = hasReceivedMemoryWarning ? 'Received' : 'No';
    this.setState({ memoryWarning });

    const textAttachment = await AttachmentsProvider.getTextAttachment();
    this.setState({ textAttachment });

    const binaryAttachment = await AttachmentsProvider.getBinaryAttachmentInfo();
    this.setState({ binaryAttachment });

    this.props.navigation.setParams({
      refreshCrash: this.refreshToggle.bind(this)