expo-playcore-in-app-update 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # expo-in-app-update
2
+
3
+ Android in-app update module for Expo (Immediate update).
4
+
5
+ ## Installation
6
+
7
+ npx expo install expo-in-app-update
8
+
9
+ ## Usage
10
+
11
+ import { triggerImmediateUpdate } from 'expo-in-app-update';
12
+
13
+ useEffect(() => {
14
+ triggerImmediateUpdate();
15
+ }, []);
16
+
17
+ ## Platform
18
+ - Android only
@@ -0,0 +1,23 @@
1
+ plugins {
2
+ id 'com.android.library'
3
+ id 'expo-module-gradle-plugin'
4
+ }
5
+
6
+ group = 'expo.modules.inappupdate'
7
+ version = '0.0.1'
8
+
9
+ android {
10
+ namespace "expo.modules.inappupdate"
11
+ defaultConfig {
12
+ versionCode 1
13
+ versionName "0.0.1"
14
+ }
15
+ lintOptions {
16
+ abortOnError false
17
+ }
18
+ }
19
+
20
+ dependencies {
21
+ implementation("com.google.android.play:app-update:2.1.0")
22
+ implementation("com.google.android.play:app-update-ktx:2.1.0")
23
+ }
@@ -0,0 +1,2 @@
1
+ <manifest>
2
+ </manifest>
@@ -0,0 +1,52 @@
1
+ package expo.modules.inappupdate
2
+
3
+ import android.util.Log
4
+ import com.google.android.play.core.appupdate.AppUpdateManagerFactory
5
+ import com.google.android.play.core.appupdate.AppUpdateOptions
6
+ import com.google.android.play.core.install.model.AppUpdateType
7
+ import com.google.android.play.core.install.model.UpdateAvailability
8
+ import expo.modules.kotlin.modules.Module
9
+ import expo.modules.kotlin.modules.ModuleDefinition
10
+
11
+ class ExpoInAppUpdateModule : Module() {
12
+ private val TAG = "ExpoInAppUpdate"
13
+ // A unique code to identify the update request
14
+ private val UPDATE_REQUEST_CODE = 9001
15
+
16
+ override fun definition() = ModuleDefinition {
17
+ Name("ExpoInAppUpdate")
18
+
19
+ Function("triggerImmediateUpdate") {
20
+ val activity = appContext.currentActivity ?: return@Function null
21
+ val appUpdateManager = AppUpdateManagerFactory.create(activity)
22
+
23
+ Log.i(TAG, "Requesting app update info...")
24
+ val appUpdateInfoTask = appUpdateManager.appUpdateInfo
25
+
26
+ appUpdateInfoTask.addOnSuccessListener { info ->
27
+ Log.i(TAG, "App update info received. UpdateAvailability: ${info.updateAvailability()}, AvailableVersionCode: ${info.availableVersionCode()}")
28
+
29
+ // Check if an update is available and if "Immediate" is allowed
30
+ if (info.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
31
+ info.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
32
+ ) {
33
+ Log.i(TAG, "Immediate update is available and allowed. Starting update flow...")
34
+ // For Play Core 2.1.0, we MUST use the AppUpdateOptions builder
35
+ val options = AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build()
36
+
37
+ // Correct Signature: (info, activity, options, requestCode)
38
+ appUpdateManager.startUpdateFlowForResult(
39
+ info,
40
+ activity,
41
+ options,
42
+ UPDATE_REQUEST_CODE
43
+ )
44
+ } else {
45
+ Log.i(TAG, "No immediate update available, or not allowed for this update.")
46
+ }
47
+ }.addOnFailureListener { exception ->
48
+ Log.e(TAG, "Failed to fetch app update info from Play Store", exception)
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,2 @@
1
+ export declare function triggerImmediateUpdate(): any;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,QAMrC"}
package/build/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { requireOptionalNativeModule } from 'expo-modules-core';
2
+ import { Platform } from 'react-native';
3
+ // This links to the "Name" we define in the Kotlin file
4
+ // We use requireOptionalNativeModule so it doesn't crash on iOS since we deleted the iOS module
5
+ const ExpoInAppUpdate = requireOptionalNativeModule('ExpoInAppUpdate');
6
+ export function triggerImmediateUpdate() {
7
+ if (Platform.OS !== 'android' || !ExpoInAppUpdate) {
8
+ console.warn("In-App Updates are only supported on Android.");
9
+ return;
10
+ }
11
+ return ExpoInAppUpdate.triggerImmediateUpdate();
12
+ }
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,wDAAwD;AACxD,gGAAgG;AAChG,MAAM,eAAe,GAAG,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;AAEvE,MAAM,UAAU,sBAAsB;IAClC,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QAC9D,OAAO;IACX,CAAC;IACD,OAAO,eAAe,CAAC,sBAAsB,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import { requireOptionalNativeModule } from 'expo-modules-core';\r\nimport { Platform } from 'react-native';\r\n\r\n// This links to the \"Name\" we define in the Kotlin file\r\n// We use requireOptionalNativeModule so it doesn't crash on iOS since we deleted the iOS module\r\nconst ExpoInAppUpdate = requireOptionalNativeModule('ExpoInAppUpdate');\r\n\r\nexport function triggerImmediateUpdate() {\r\n if (Platform.OS !== 'android' || !ExpoInAppUpdate) {\r\n console.warn(\"In-App Updates are only supported on Android.\");\r\n return;\r\n }\r\n return ExpoInAppUpdate.triggerImmediateUpdate();\r\n}"]}
@@ -0,0 +1,10 @@
1
+ {
2
+ "platforms": [
3
+ "android"
4
+ ],
5
+ "android": {
6
+ "modules": [
7
+ "expo.modules.inappupdate.ExpoInAppUpdateModule"
8
+ ]
9
+ }
10
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "expo-playcore-in-app-update",
3
+ "version": "0.0.1",
4
+ "description": "Expo module for Android in-app updates using Play Core API",
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
7
+ "scripts": {
8
+ "build": "expo-module build",
9
+ "clean": "expo-module clean"
10
+ },
11
+ "keywords": [
12
+ "react-native",
13
+ "expo",
14
+ "expo-in-app-update",
15
+ "ExpoInAppUpdate"
16
+ ],
17
+ "repository": "https://github.com/yasirarafath-muvnw/expo-in-app-update",
18
+ "bugs": {
19
+ "url": "https://github.com/yasirarafath-muvnw/expo-in-app-update/issues"
20
+ },
21
+ "author": "Yasir Arafath <yasir.arafath.munvw@gmail.com> (https://github.com/yasirarafath-muvnw)",
22
+ "license": "MIT",
23
+ "homepage": "https://github.com/yasirarafath-muvnw/expo-in-app-update#readme",
24
+ "devDependencies": {
25
+ "@types/react": "~19.1.1",
26
+ "expo-module-scripts": "^55.0.2",
27
+ "expo": "^55.0.8",
28
+ "react-native": "0.82.1"
29
+ },
30
+ "peerDependencies": {
31
+ "expo": "*",
32
+ "react": "*",
33
+ "react-native": "*"
34
+ },
35
+ "files": [
36
+ "build",
37
+ "android",
38
+ "expo-module.config.json"
39
+ ],
40
+ "packageManager": "yarn@1.22.22"
41
+ }