I have created an account at Onesignal website and got my App ID,
and installed react-native-onesignal version ^4.0.3.
React Native ver: 0.63.4
Copy pasted the config on the documentation
useEffect(() => {
/* O N E S I G N A L S E T U P */
OneSignal.setAppId("MY_APP_ID");
OneSignal.setLogLevel(6, 0);
OneSignal.setRequiresUserPrivacyConsent(false);
OneSignal.promptForPushNotificationsWithUserResponse(response => {
OSLog("Prompt response:", response);
});
}, [])
But im getting error:
null is not an object evaluating 'RNOneSigna l.setAppId',
The same here, the documentation is incomplete and only available in class components, 2021 using clases, yep: Onesignal.
The second if you browse into the /examples you will only find in TS.
Use this repo, it's better than Onesignal:
Thanks for the example it was helpfull, I also got it working now I just redo the installation and the linking,
this might also help for android:
build.gradle
------------------------------------------------
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.9, 0.99.99]'
}
}
app/build.gradle
-------------------------------------------------
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
dependencies {
......
implementation 'com.google.android.gms:play-services-location:+'
......
md5-486be793a7326f5626a5b31fa8aa3baa
-------------------------------------------------------------------
androidmanifest.xml add android:launchMode="singleTask"
-------------------------------------------------------------------
<activity
android:name=".MainActivity"
android:label="xxxxxxxxxxxxxxxxxx"
android:launchMode="singleTask"> <!-- Add this attribute to your main activity -->
</activity>
Then I initialized using the sample from @TrejoCode
I love the collaboration! Thanks @TrejoCode
I have the same problem. Link to example from @TrejoCode isn't working? Any help?
I have the same problem. Link to example from @TrejoCode isn't working? Any help?
Perhaps in the future there will be an answer stackoverflow
Most helpful comment
The same here, the documentation is incomplete and only available in class components, 2021 using clases, yep: Onesignal.
The second if you browse into the /examples you will only find in TS.
Use this repo, it's better than Onesignal:
Example