Showing posts with label React Native. Show all posts
Showing posts with label React Native. Show all posts

Tuesday, 15 September 2020

Webview in react native

 Create Project....................................

Cmd : npx react-native init Projectname




Webview -------------------------------------------

https://blog.logrocket.com/the-complete-guide-to-react-native-webview/

Cmd

yarn add react-native-webview

npx react-native link react-native-webview




//This is an example code to understand WebView// 


import React, { Component } from 'react';

//import react in our code. 


import { WebView } from "react-native-webview";

//import all the components we are going to use. 


export default class App extends Component {

  render() {

    return (

       <WebView

        source={{uri: 'https://eleader.in/'}}

        style={{marginTop: 0}}

      />

    );

  }



add this code

android/src/AndroidManifest.xml


 android:icon="@mipmap/ic_launcher" After

 android:usesCleartextTraffic="true"

-----------------------------------------------------------

Build Bundle & Apk in React Native

https://www.youtube.com/watch?v=SzwTGDDXTAE

Doc : 

https://reactnative.dev/docs/signed-apk-android


keytool -genkeypair -v -keystore aagajkiaawaj.keystore -alias aagajkiaawaj -keyalg RSA -keysize 2048 -validity 20000




Build Apk......................


cd android

gradlew assembleRelease



Build Bundle......................


cd android

gradlew bundleRelease

---------------------------- 

notification onesignal react native

 Notification One Siganal ---------------------------------


https://www.youtube.com/watch?v=S2ubIsjdKgk&t=129s

 https://bitbucket.org/shagun123/react-native-one-signal/src/master/

 https://documentation.onesignal.com/docs/react-native-sdk-setup


cmd : 

yarn add react-native-onesignal

npx react-native link react-native-onesignal



1. App.js

import OneSignal from 'react-native-onesignal';

//export default class App extends Component {


componentDidMount() {

        OneSignal.init('81a9dced-2283-4acf-985a-79c6d552119b');

        OneSignal.addEventListener('received', (data) => {

            console.log(data);

        });

        OneSignal.inFocusDisplaying(2);

    }


    componentWillUnmount() {

        OneSignal.removeEventListener('received');

    }



---------------------------------------------------------

2. android\app\src\main\AndroidManifest.xml

<application ....>
  <activity
    android:name=".MainActivity"
    android:label="OneSignal Example"
    android:launchMode="singleTask"> <!-- Add this attribute to your main activity -->
  </activity>

3. android\app\build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile
after top 2 line add code
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

Tuesday, 8 September 2020

React Native Doc

 1. Build expo react native app  [ .apk .abb]

Video : https://www.youtube.com/watch?v=ueJjgLbWxsY


Expo URL:

https://expo.io/ 

https://expo.io/signup 

https://expo.io/login


Start Application 

cmd : expo start Build apk 

cmd : expo build:android