Reputation: 2563
I want to add onesignal push notification to expo project.
However, i need to add something like this :
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
to
app/build.grandle
but expo project doesnt include build.grandle folder
how can i handle this
Upvotes: 0
Views: 978
Reputation: 868
OneSignal added support for Expo bare workflow, see the official documentation on how to install it: https://documentation.onesignal.com/docs/react-native-expo-sdk-setup
The short answer is you can't.
Checkout The only supported third-party push notification service is the Expo notification service.
If you want to use OneSignal with expo, you have to eject to the bare workflow. Here's a link to OneSignal documentation: Must eject to bare workflow
Upvotes: 2
Reputation: 129
Follow below steps:
expo install onesignal-expo-plugin
npm install --save react-native-onesignal
In your app.json add
{
"plugins": [
[
"onesignal-expo-plugin",
{
"mode": "development",
}
]
]
}
Run npx expo prebuild
In one terminal run this
npx expo start --dev-client
Then in another terminal run this
npm run android
Now add this in your code
import { LogLevel, OneSignal } from "react-native-onesignal";
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize("Your-Api-Key");
const player_id = OneSignal.User.pushSubscription.getPushSubscriptionId();
Upvotes: 0
Reputation: 755
Native Notify (https://nativenotify.com) is the only Expo push notification service I know of that works with Expo.
I think Native Notify was designed specifically to be an Expo posh notification service.
It was SOOOO easy to set up. I was set up in 5 minutes.
Upvotes: 0