How to add onesignal to expo project - react-native

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

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

Related

How to clear gradle to reinstall npm package (React Native Android)

I have an issue with an npm package react-native-video where it says 'no variant found for :react-native-video.' I've tried uninstalling and reinstalling, deleting node_modules and yarn.lock and clearing gradle, invalidating caches and restarting Android Studio, and any permutation of the above things.
The app builds and syncs perfectly find without react-native-video, but any time I reinstall it and add the files back in the app.gradle and other files (per the installation instructions) it gives me the same error. Has anyone had this issue before, and how do you fix it? I'm assuming it's an Android Studio/Gradle issue, but I'm at a complete loss as to how to fix it.
Please check your version of React Native and react-native-video.
In my case, I use React Native 0.64.1 and react-native-video 5.1.1, and it works well.
Other solution
Assuming you are on a later version of React Native, In android/build.gradle you need to add jcenter(), in this case best to be explicit and only include what is necessary:
...
allprojects {
repositories {
... other repositories
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
}
}

How to add persona react-native sdk in android

I'm trying to implement digital verification in my app. I have done the iOS implementation now working on android In persona they have no documentation on the react-native page for android.
What I should do to move to native implementation or search for auto-linking?
I have followed the Native implementation with the package and my App showing me the personal screens successfully.
here is Doc lin
https://docs.withpersona.com/docs/android-sdk-integration-guide
Step 1:
add this into app/build.gradle
maven { url 'https://sdk.withpersona.com/android/releases' }
Step 2:
add these line in app/src/build.gradle
implementation 'com.withpersona.sdk:inquiry:1.1.1'

App crash when add react-native-firebase/admob

How to add react-native-firebase admob to react native ("0.60.x"). App crash when adding admob. Are there any other option to add admob to react-native app. react-native-admob also the same crashing problem.
Within the root of your React Native project, create a firebase.json file (if it doesn't already exist) and add the admob_android_app_id & admob_ios_app_id keys with the IDs from the Google AdMob console:
Like:
{
"react-native": {
"admob_android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"admob_ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
}
}

react-native-maps production: app crashes when opening basic <Mapview/>

I am unable to integrate react-natives-maps in a production build as I am unsure how to set it up with expo and react native 0.61.
Am I supposed to create a android/build.gradle file to make this work? Till now I wasn't needing this file as everything is handled by expo. I also don't have any other files in the android/ folder. This is the build.gradle that I have added:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'de.undercouch:gradle-download-task:4.0.0'
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
but I am actually unsure whether this file is used at all when I run expo build:android.
I have created the gradle file according to the installation instructions here, specifically for the 0.61 version.
When I open the APK-file after running expo build:android the screen simply crashes which make me think somehow react-native-maps is not linked properly. I am not getting any error as the app simply restart.
Depending on how you have created your react-native project with Expo will determine what folders are available and how you install dependencies.
By default Expo abstracts away the native iOS and Android code so that you do not have to worry about it.
As you project does not have and ios and android folders, this means that you are using a managed workflow which means you cannot install dependencies that add native code.
Expo provides MapView which is what you are looking for. You can install it by following the instructions here.
Basically, as you are using a managed workflow, you should use:
expo install react-native-maps
You shouldn't be adding ios or android folders to a managed workflow application as that won't do anything.

React Native: Is it possible to use Expo just for development?

I am new to Expo but so far it seems super neat not having to open up Android Studio / Xcode to run my app locally. Not having to touch that stuff makes it so much more convenient to develop.
However, I want to incorporate in app purchases (subscriptions) in my app and from the research I've done so far it doesn't seem like Expo's solution (https://docs.expo.io/versions/latest/sdk/in-app-purchases/) is very developed.
I found this npm package for in app purchases and it looks promising: https://github.com/dooboolab/react-native-iap. However it is not supported by Expo, and I don't feel like it's worth giving up all the benefits of Expo just for this one feature.
I noticed a comment in the issues here that was quite intriguing: https://github.com/dooboolab/react-native-iap/issues/174#issuecomment-393704277
This person suggests that I can continue using the master branch with Expo, and then following these steps to eject and deploy when time is ready. I've never done this, but I'm wondering if this could work:
On master:
1) Run npm install --save react-native-iap but DON'T run react-native link react-native-iap.
2) Wrap my In App Purchase module with this code. This way your code won't crash when calling IAP methods
import { NativeModules } from 'react-native';
const { RNIapModule } = NativeModules;
function hasIAP() {
return !!NativeModules.RNIapModule;
}
3) Continue developing using Expo, and just skipping the IAP stuff if !hasIAP()
On separate branch used for final QA / deployment:
1) Create a new branch called detached
2) Run expo eject
3) Run react-native link react-native-iap and all the other Manual Installation steps listed here: https://github.com/dooboolab/react-native-iap#manual-installation
4) QA everything
5) Deploy
Does anyone have experience doing this hybrid "expo for development, no expo for production" approach?
If you eject and use the Expo, you can use it like a default React-native project. The Android folder and the iOS folder are created and you will enter the appropriate package name before you create them. The modules you have installed and the modules in Expo are added to the package list when you eject the Expo. Check MainApplication.java for Android or Info.list files for iOS. There are some things that do not apply to App.json settings that were responsible for setting up after you ejected the Expo. It can be set up by referring to the official document.
Once the Expo has been ejected, the React-native link command is performed brilliantly.
ejecting the Expo does not change or disappear from the module usage