Skip to content

Commit 806cc85

Browse files
committed
initial plugin code commit
1 parent 0c62efa commit 806cc85

20 files changed

+1145
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
package-lock.json
25+
26+
# Android/IntelliJ
27+
#
28+
build/
29+
.idea
30+
.gradle
31+
local.properties
32+
*.iml
33+
34+
# node.js
35+
#
36+
node_modules/
37+
npm-debug.log
38+
yarn-error.log
39+
yarn.lock
40+
41+
# BUCK
42+
buck-out/
43+
\.buckd/
44+
*.keystore
45+
!debug.keystore
46+
47+
# fastlane
48+
#
49+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
50+
# screenshots whenever they are needed.
51+
# For more information about the recommended setup visit:
52+
# https://docs.fastlane.tools/best-practices/source-control/
53+
54+
*/fastlane/report.xml
55+
*/fastlane/Preview.html
56+
*/fastlane/screenshots
57+
58+
# Bundle artifact
59+
*.jsbundle
60+
61+
# CocoaPods
62+
/ios/Pods/
63+
android/barnabas.jks
64+
android/app/release/

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# react-native-rn-in-app-update
2+
3+
## Getting started
4+
5+
`$ npm install react-native-rn-in-app-update --save`
6+
7+
### Manual installation for (RN < 0.60)
8+
9+
`$ react-native link react-native-rn-in-app-update`
10+
11+
## Add Below Lines in MainActivity.java
12+
13+
=> Import package:
14+
import com.logicwind.inappupdate.InAppUpdateUtils;
15+
16+
=> Create object :
17+
private InAppUpdateUtils appUpdateUtils;
18+
19+
=> Add below lines in OnCreate method :
20+
appUpdateUtils = new InAppUpdateUtils(this);
21+
appUpdateUtils.initAppUpdaterAndCheckForUpdate();
22+
appUpdateUtils.registerListener();
23+
24+
=> Add below methods also :
25+
@Override
26+
protected void onResume() {
27+
super.onResume();
28+
appUpdateUtils.ifUpdateDownloadedThenInstall();
29+
}
30+
31+
@Override
32+
protected void onDestroy() {
33+
super.onDestroy();
34+
appUpdateUtils.unregisterListener();
35+
}

android/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# react-native-rn-in-app-update
2+
3+
## Getting started
4+
5+
`$ npm install react-native-rn-in-app-update --save`
6+
7+
### Manual installation for (RN < 0.60)
8+
9+
`$ react-native link react-native-rn-in-app-update`
10+
11+
## Add Below Lines in MainActivity.java
12+
13+
=> Import package:
14+
import com.logicwind.inappupdate.InAppUpdateUtils;
15+
16+
=> Create object :
17+
private InAppUpdateUtils appUpdateUtils;
18+
19+
=> Add below lines in OnCreate method :
20+
appUpdateUtils = new InAppUpdateUtils(this);
21+
appUpdateUtils.initAppUpdaterAndCheckForUpdate();
22+
appUpdateUtils.registerListener();
23+
24+
=> Add below methods also :
25+
@Override
26+
protected void onResume() {
27+
super.onResume();
28+
appUpdateUtils.ifUpdateDownloadedThenInstall();
29+
}
30+
31+
@Override
32+
protected void onDestroy() {
33+
super.onDestroy();
34+
appUpdateUtils.unregisterListener();
35+
}

android/build.gradle

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// android/build.gradle
2+
3+
// based on:
4+
//
5+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6+
// original location:
7+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8+
//
9+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10+
// original location:
11+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12+
13+
def DEFAULT_COMPILE_SDK_VERSION = 28
14+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
15+
def DEFAULT_MIN_SDK_VERSION = 16
16+
def DEFAULT_TARGET_SDK_VERSION = 28
17+
18+
def safeExtGet(prop, fallback) {
19+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
apply plugin: 'maven'
24+
25+
buildscript {
26+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
27+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
28+
// module dependency in an application project.
29+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
30+
if (project == rootProject) {
31+
repositories {
32+
google()
33+
jcenter()
34+
}
35+
dependencies {
36+
classpath 'com.android.tools.build:gradle:3.4.1'
37+
}
38+
}
39+
}
40+
41+
apply plugin: 'com.android.library'
42+
apply plugin: 'maven'
43+
44+
android {
45+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
46+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
47+
defaultConfig {
48+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
49+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
50+
versionCode 1
51+
versionName "1.0"
52+
}
53+
lintOptions {
54+
abortOnError false
55+
}
56+
compileOptions {
57+
sourceCompatibility = 1.8
58+
targetCompatibility = 1.8
59+
}
60+
}
61+
62+
repositories {
63+
// ref: https://www.baeldung.com/maven-local-repository
64+
mavenLocal()
65+
maven {
66+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
67+
url "$rootDir/../node_modules/react-native/android"
68+
}
69+
maven {
70+
// Android JSC is installed from npm
71+
url "$rootDir/../node_modules/jsc-android/dist"
72+
}
73+
google()
74+
jcenter()
75+
}
76+
77+
dependencies {
78+
//noinspection GradleDynamicVersion
79+
implementation 'com.facebook.react:react-native:+' // From node_modules
80+
implementation 'com.google.android.play:core:1.7.3'
81+
}
82+
83+
def configureReactNativePom(def pom) {
84+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
85+
86+
pom.project {
87+
name packageJson.title
88+
artifactId packageJson.name
89+
version = packageJson.version
90+
group = "com.reactlibrary.inappupdate"
91+
description packageJson.description
92+
url packageJson.repository.baseUrl
93+
94+
licenses {
95+
license {
96+
name packageJson.license
97+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
98+
distribution 'repo'
99+
}
100+
}
101+
102+
developers {
103+
developer {
104+
id packageJson.author.username
105+
name packageJson.author.name
106+
}
107+
}
108+
}
109+
}
110+
111+
afterEvaluate { project ->
112+
// some Gradle build hooks ref:
113+
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
114+
task androidJavadoc(type: Javadoc) {
115+
source = android.sourceSets.main.java.srcDirs
116+
classpath += files(android.bootClasspath)
117+
classpath += files(project.getConfigurations().getByName('compile').asList())
118+
include '**/*.java'
119+
}
120+
121+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
122+
classifier = 'javadoc'
123+
from androidJavadoc.destinationDir
124+
}
125+
126+
task androidSourcesJar(type: Jar) {
127+
classifier = 'sources'
128+
from android.sourceSets.main.java.srcDirs
129+
include '**/*.java'
130+
}
131+
132+
android.libraryVariants.all { variant ->
133+
def name = variant.name.capitalize()
134+
def javaCompileTask = variant.javaCompileProvider.get()
135+
136+
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
137+
from javaCompileTask.destinationDir
138+
}
139+
}
140+
141+
artifacts {
142+
archives androidSourcesJar
143+
archives androidJavadocJar
144+
}
145+
146+
task installArchives(type: Upload) {
147+
configuration = configurations.archives
148+
repositories.mavenDeployer {
149+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
150+
repository url: "file://${projectDir}/../android/maven"
151+
configureReactNativePom pom
152+
}
153+
}
154+
}
53.1 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Sat Jun 27 19:12:06 IST 2020
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

0 commit comments

Comments
 (0)