Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Trying to catch error on promptForPushNotificationsWithUserResponse #1509

Closed
1 task done
ajouve opened this issue Mar 31, 2023 · 5 comments
Closed
1 task done

Comments

@ajouve
Copy link

ajouve commented Mar 31, 2023

How can we help?

Hello,

I have the exact same error for some of my users #1449

I tried to do something like that to prevent it

export async function init() {
  try {
    OneSignal.setAppId('xxx');

    try {
      // https://github.com/OneSignal/react-native-onesignal/issues/1449
      OneSignal.promptForPushNotificationsWithUserResponse();
    } catch (error) {
      if (Platform.OS !== 'android') {
        throw error;
      }
      await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
      );
    }

  } catch (error) {
    logError(error);
  }
}

But the error is not catch, is it normal ?

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jennantilla
Copy link
Contributor

Hi @ajouve, thanks for reaching out! Based on the other issue you linked, it sounds like you are getting a crash when calling OneSignal.promptForPushNotificationsWithUserResponse(), so you implemented PermissionsAndroid as a workaround?

Can you share a bit more about the expected outcome of the code snippet you shared vs. what is happening instead?

Any additional details about your setup would be helpful as well! What version of react-native are you using? What is your current compileSdkVersion?

Thanks!

@ajouve ajouve changed the title [question]: Trying to cathe error on promptForPushNotificationsWithUserResponse [question]: Trying to catch error on promptForPushNotificationsWithUserResponse Apr 7, 2023
@ajouve
Copy link
Author

ajouve commented Apr 7, 2023

I am not able to reproduce this issue, I only have the logs threw sentry

RuntimeException
Could not invoke OneSignal.promptForPushNotificationsWithUserResponse

This is my build.gradle

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        supportLibVersion = "28.0.0"

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.3.14'
    }
}

I am using react-native 0.71.2

@hkanizawa
Copy link

@ajouve I've tried the same solution here. Did you solve it?

@ajouve
Copy link
Author

ajouve commented May 2, 2023

@hkanizawa Nothing for now

I can not reproduce the issue on my phones, I do not know if it causes a crash

@jennantilla
Copy link
Contributor

Hello everyone! Apologies that this issue has gone stale. Since it has been some time since this issue has seen any discussion, I'll go ahead and close it out.

If this is still a concern for anyone, please @ mention me and we will renew investigation.

We have a new major release update for our React Native SDK that includes many improvements and enhancements. I encourage everyone to upgrade! Please see our migration guide for full details.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants