rnn
rnn

Reputation: 2563

How to add onesignal to expo project

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

Answers (3)

abdou-tech
abdou-tech

Reputation: 868

EDIT 2024

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



Original answer

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

Manish kumar
Manish kumar

Reputation: 129

Follow below steps:

  1. expo install onesignal-expo-plugin

  2. npm install --save react-native-onesignal

  3. In your app.json add

{
  "plugins": [
    [
      "onesignal-expo-plugin",
      {
        "mode": "development",
      }
    ]
  ]
}

  1. Run npx expo prebuild

  2. In one terminal run this

    npx expo start --dev-client

  3. Then in another terminal run this

    npm run android

  4. Now add this in your code

import { LogLevel, OneSignal } from "react-native-onesignal";

OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize("Your-Api-Key");

  1. And to get player Id

    const player_id = OneSignal.User.pushSubscription.getPushSubscriptionId();

Upvotes: 0

Page COW
Page COW

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

Related Questions