Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ proguard/
# Android Studio captures folder
captures/

# Remove after this framework is published on NPM
code-push-plugin-testing-framework/node_modules

# Windows
windows/.vs/
windows/obj/
Expand Down Expand Up @@ -192,4 +189,4 @@ Examples/testapp_rn

# Android debug build files (conflict ignoring #Visual Studio files)
!android/app/src/debug/
.temp/
.temp/
4 changes: 1 addition & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ Recipes/
bin/
test/

# Remove after this framework is published on NPM
code-push-plugin-testing-framework/

# Android build artifacts and Android Studio bits
android/build
android/app/build
android/local.properties
android/.gradle
Expand Down
23 changes: 21 additions & 2 deletions AlertAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ import React, { Platform } from "react-native";
let { Alert } = React;

if (Platform.OS === "android") {
const { NativeModules: { CodePushDialog } } = React;
function resolveNativeModule(name) {
const ReactNative = require("react-native");
try {
const turboModule =
ReactNative.TurboModuleRegistry && ReactNative.TurboModuleRegistry.get
? ReactNative.TurboModuleRegistry.get(name)
: null;
if (turboModule) return turboModule;
} catch (_e) {
// Ignore and fall back to legacy NativeModules.
}

return ReactNative.NativeModules ? ReactNative.NativeModules[name] : null;
}

const CodePushDialog = resolveNativeModule("CodePushDialog");

Alert = {
alert(title, message, buttons) {
Expand All @@ -13,6 +28,10 @@ if (Platform.OS === "android") {
const button1Text = buttons[0] ? buttons[0].text : null,
button2Text = buttons[1] ? buttons[1].text : null;

if (!CodePushDialog) {
throw "CodePushDialog native module is not installed.";
}

CodePushDialog.showDialog(
title, message, button1Text, button2Text,
(buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
Expand All @@ -21,4 +40,4 @@ if (Platform.OS === "android") {
};
}

module.exports = { Alert };
module.exports = { Alert };
17 changes: 16 additions & 1 deletion CodePush.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ import { AppState, Platform } from "react-native";
import log from "./logging";
import hoistStatics from 'hoist-non-react-statics';

let NativeCodePush = require("react-native").NativeModules.CodePush;
function resolveNativeModule(name) {
const ReactNative = require("react-native");
try {
const turboModule =
ReactNative.TurboModuleRegistry && ReactNative.TurboModuleRegistry.get
? ReactNative.TurboModuleRegistry.get(name)
: null;
if (turboModule) return turboModule;
} catch (_e) {
// Ignore and fall back to legacy NativeModules.
}

return ReactNative.NativeModules ? ReactNative.NativeModules[name] : null;
}

let NativeCodePush = resolveNativeModule("CodePush");
const PackageMixins = require("./package-mixins")(NativeCodePush);

async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchCallback = null) {
Expand Down
4 changes: 2 additions & 2 deletions CodePush.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Pod::Spec.new do |s|
s.license = package['license']
s.homepage = package['homepage']
s.source = { :git => 'https://github.com/srcpush/react-native-code-push.git', :tag => "v#{s.version}"}
s.ios.deployment_target = '15.5'
s.tvos.deployment_target = '15.5'
s.ios.deployment_target = '11.0'
s.tvos.deployment_target = '11.0'
s.preserve_paths = '*.js'
s.library = 'z'
s.source_files = 'ios/CodePush/*.{h,m}'
Expand Down
98 changes: 74 additions & 24 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,98 @@
apply plugin: "com.android.library"

def isNewArchitectureEnabled() {
// To opt-in for the New Architecture, you can either:
// - Set `newArchEnabled` to true inside the `gradle.properties` file
// - Invoke gradle with `-newArchEnabled=true`
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}
import groovy.json.JsonSlurper

def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
apply plugin: "com.android.library"

if (IS_NEW_ARCHITECTURE_ENABLED) {
apply plugin: "com.facebook.react"
def safeExtGet(prop, fallback) {
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def DEFAULT_COMPILE_SDK_VERSION = 26
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_MIN_SDK_VERSION = 16

def findReactNativePackageJson() {
File currentDir = projectDir

while (currentDir != null) {
File packageJson = new File(currentDir, "node_modules/react-native/package.json")
if (packageJson.exists()) {
return packageJson
}

currentDir = currentDir.parentFile
}

return null
}

def getReactNativeVersion() {
File packageJson = findReactNativePackageJson()
if (packageJson == null) {
return null
}

def version = new JsonSlurper().parseText(packageJson.text).version
return version.tokenize("-")[0]
}

def getReactNativeMinorVersion() {
def reactNativeVersion = getReactNativeVersion()
if (reactNativeVersion == null) {
return null
}

def versionParts = reactNativeVersion.tokenize(".")
if (versionParts.size() < 2) {
return null
}

return versionParts[1].toInteger()
}

def reactNativeVersion = getReactNativeVersion()
def reactNativeMinorVersion = getReactNativeMinorVersion()
def reactNativeDependency = reactNativeMinorVersion != null && reactNativeMinorVersion < 71
? "com.facebook.react:react-native:${reactNativeVersion ?: '+'}"
: "com.facebook.react:react-android:${reactNativeVersion ?: '+'}"

android {
namespace "com.microsoft.codepush.react"
if (project.android.hasProperty("namespace")) {
namespace "com.microsoft.codepush.react"
}

compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)

defaultConfig {
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
minSdkVersion safeExtGet("minSdkVersion", DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet("targetSdkVersion", DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", IS_NEW_ARCHITECTURE_ENABLED.toString()
consumerProguardFiles "../proguard-rules.pro"
}

sourceSets {
main {
java.srcDirs = ["../src/main/java"]
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
abortOnError false
}
}

defaultConfig {
consumerProguardFiles 'proguard-rules.pro'
}
repositories {
google()
mavenCentral()
mavenLocal()
}

dependencies {
implementation "com.facebook.react:react-native:+"
implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
implementation(reactNativeDependency)
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
}
6 changes: 0 additions & 6 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

<application>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>
7 changes: 2 additions & 5 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.codepush.react" />

This file was deleted.

100 changes: 91 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,106 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import groovy.json.JsonSlurper

buildscript {
ext {
kotlinVersion = "1.9.24"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath("com.android.tools.build:gradle:8.2.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}

apply plugin: "com.android.library"

def safeExtGet(prop, fallback) {
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def DEFAULT_COMPILE_SDK_VERSION = 26
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_MIN_SDK_VERSION = 16

def findReactNativePackageJson() {
File currentDir = projectDir

while (currentDir != null) {
File packageJson = new File(currentDir, "node_modules/react-native/package.json")
if (packageJson.exists()) {
return packageJson
}

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
currentDir = currentDir.parentFile
}

return null
}

def getReactNativeVersion() {
File packageJson = findReactNativePackageJson()
if (packageJson == null) {
return null
}

def version = new JsonSlurper().parseText(packageJson.text).version
return version.tokenize("-")[0]
}

allprojects {
android {
def getReactNativeMinorVersion() {
def reactNativeVersion = getReactNativeVersion()
if (reactNativeVersion == null) {
return null
}

def versionParts = reactNativeVersion.tokenize(".")
if (versionParts.size() < 2) {
return null
}

return versionParts[1].toInteger()
}

def reactNativeVersion = getReactNativeVersion()
def reactNativeMinorVersion = getReactNativeMinorVersion()
def reactNativeDependency = reactNativeMinorVersion != null && reactNativeMinorVersion < 71
? "com.facebook.react:react-native:${reactNativeVersion ?: '+'}"
: "com.facebook.react:react-android:${reactNativeVersion ?: '+'}"

android {
if (project.android.hasProperty("namespace")) {
namespace "com.microsoft.codepush.react"
}
repositories {
mavenLocal()
mavenCentral()

compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)

defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet("targetSdkVersion", DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
consumerProguardFiles "proguard-rules.pro"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
abortOnError false
}
}

repositories {
google()
mavenCentral()
mavenLocal()
}

dependencies {
implementation(reactNativeDependency)
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
}
6 changes: 3 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useDeprecatedNdk=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
File renamed without changes.
1 change: 0 additions & 1 deletion android/settings.gradle

This file was deleted.

Loading
Loading