appsonair-react-native-apppush 0.0.1-alpha

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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +540 -0
  3. package/android/build.gradle +177 -0
  4. package/android/gradle.properties +15 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModuleImpl.kt +767 -0
  8. package/android/src/main/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushPackage.kt +43 -0
  9. package/android/src/newarch/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModule.kt +199 -0
  10. package/android/src/oldarch/java/com/appsonairreactnativeapppush/AppsonairReactNativeApppushModule.kt +249 -0
  11. package/appsonair-react-native-apppush.podspec +77 -0
  12. package/ios/AppsonairReactNativeApppush-Bridging-Header.h +12 -0
  13. package/ios/AppsonairReactNativeApppush.h +28 -0
  14. package/ios/AppsonairReactNativeApppush.mm +494 -0
  15. package/ios/AppsonairReactNativeApppushImpl.swift +594 -0
  16. package/lib/commonjs/NativeAppsonairApppush.js +48 -0
  17. package/lib/commonjs/NativeAppsonairApppush.js.map +1 -0
  18. package/lib/commonjs/index.js +686 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/types.js +2 -0
  21. package/lib/commonjs/types.js.map +1 -0
  22. package/lib/module/NativeAppsonairApppush.js +47 -0
  23. package/lib/module/NativeAppsonairApppush.js.map +1 -0
  24. package/lib/module/index.js +612 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/types.js +2 -0
  27. package/lib/module/types.js.map +1 -0
  28. package/lib/typescript/commonjs/package.json +1 -0
  29. package/lib/typescript/commonjs/src/NativeAppsonairApppush.d.ts +134 -0
  30. package/lib/typescript/commonjs/src/NativeAppsonairApppush.d.ts.map +1 -0
  31. package/lib/typescript/commonjs/src/index.d.ts +392 -0
  32. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  33. package/lib/typescript/commonjs/src/types.d.ts +221 -0
  34. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  35. package/lib/typescript/module/package.json +1 -0
  36. package/lib/typescript/module/src/NativeAppsonairApppush.d.ts +134 -0
  37. package/lib/typescript/module/src/NativeAppsonairApppush.d.ts.map +1 -0
  38. package/lib/typescript/module/src/index.d.ts +392 -0
  39. package/lib/typescript/module/src/index.d.ts.map +1 -0
  40. package/lib/typescript/module/src/types.d.ts +221 -0
  41. package/lib/typescript/module/src/types.d.ts.map +1 -0
  42. package/package.json +119 -0
  43. package/react-native.config.js +14 -0
  44. package/src/NativeAppsonairApppush.ts +188 -0
  45. package/src/index.tsx +745 -0
  46. package/src/types.ts +284 -0
@@ -0,0 +1,177 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else, so getExtOrDefault is not available yet.
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion")
4
+ ? rootProject.ext.get("kotlinVersion")
5
+ : project.properties["AppsonairReactNativeApppush_kotlinVersion"]
6
+
7
+ repositories {
8
+ google()
9
+ mavenCentral()
10
+ maven { url 'https://jitpack.io' }
11
+ }
12
+
13
+ dependencies {
14
+ classpath "com.android.tools.build:gradle:7.2.1"
15
+ // noinspection DifferentKotlinGradleVersion
16
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17
+ }
18
+ }
19
+
20
+ def isNewArchitectureEnabled() {
21
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
22
+ }
23
+
24
+ apply plugin: "com.android.library"
25
+ apply plugin: "kotlin-android"
26
+
27
+ // The React Gradle plugin runs Codegen and puts the generated NativeAppsonairApppushSpec
28
+ // on the compile classpath. It is only applied on the New Architecture -- on the Old
29
+ // Architecture the spec is never generated, which is why the module class that extends
30
+ // it lives in the newarch source set rather than in main.
31
+ if (isNewArchitectureEnabled()) {
32
+ apply plugin: "com.facebook.react"
33
+ }
34
+
35
+ def getExtOrDefault(name) {
36
+ return rootProject.ext.has(name)
37
+ ? rootProject.ext.get(name)
38
+ : project.properties["AppsonairReactNativeApppush_" + name]
39
+ }
40
+
41
+ def getExtOrIntegerDefault(name) {
42
+ return rootProject.ext.has(name)
43
+ ? rootProject.ext.get(name)
44
+ : (project.properties["AppsonairReactNativeApppush_" + name]).toInteger()
45
+ }
46
+
47
+ def supportsNamespace() {
48
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
49
+ def major = parsed[0].toInteger()
50
+ def minor = parsed[1].toInteger()
51
+
52
+ // Namespace support was added in AGP 7.3.0
53
+ return (major == 7 && minor >= 3) || major >= 8
54
+ }
55
+
56
+ android {
57
+ if (supportsNamespace()) {
58
+ namespace "com.appsonairreactnativeapppush"
59
+
60
+ sourceSets {
61
+ main {
62
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
63
+ }
64
+ }
65
+ }
66
+
67
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
68
+
69
+ defaultConfig {
70
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
71
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
72
+
73
+ // Read back by AppsonairReactNativeApppushPackage to tag the module as a
74
+ // TurboModule or a legacy module. It has to be a build constant rather than a
75
+ // runtime check, because ReactModuleInfo is built before any React instance exists.
76
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
77
+ }
78
+
79
+ buildFeatures {
80
+ // Required from AGP 8 onwards, where BuildConfig generation is off by default.
81
+ buildConfig true
82
+ }
83
+
84
+ buildTypes {
85
+ release {
86
+ minifyEnabled false
87
+ }
88
+ }
89
+
90
+ lintOptions {
91
+ disable "GradleCompatible"
92
+ }
93
+
94
+ compileOptions {
95
+ sourceCompatibility JavaVersion.VERSION_17
96
+ targetCompatibility JavaVersion.VERSION_17
97
+ }
98
+
99
+ kotlinOptions {
100
+ jvmTarget = "17"
101
+
102
+ // WORKAROUND -- remove once the native SDK is republished.
103
+ //
104
+ // appsonair-android-push-notification:0.0.2-alpha is compiled with Kotlin
105
+ // 2.2.10 and sets no languageVersion/apiVersion floor, so its classes carry
106
+ // metadata 2.2.0. React Native pins the Kotlin compiler per release -- 1.9.24
107
+ // on RN 0.76, 2.0.21 on 0.77-0.78, 2.1.x on 0.79-0.81 -- and none of those can
108
+ // read metadata 2.2.0, so compiling this module against the AAR fails with:
109
+ //
110
+ // Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin.
111
+ // The actual metadata version is 2.2.0, but the compiler version 1.9.0 can
112
+ // read versions up to 2.0.0.
113
+ //
114
+ // Raising the host's Kotlin version is not an option: KGP 2.2 breaks React
115
+ // Native's own Gradle plugin ("Found interface KotlinTopLevelExtension, but
116
+ // class was expected"). The real fix is upstream -- the SDK needs
117
+ // `languageVersion = "1.9"` and `apiVersion = "1.9"` in its kotlinOptions --
118
+ // at which point this flag and the stdlib pin below both go away.
119
+ freeCompilerArgs += ["-Xskip-metadata-version-check"]
120
+ }
121
+
122
+ // The architecture-specific module class. Both source sets declare the same
123
+ // class name in the same package and differ only in what they extend, so
124
+ // exactly one of them must ever be on the compile path.
125
+ sourceSets {
126
+ main {
127
+ if (isNewArchitectureEnabled()) {
128
+ java.srcDirs += ["src/newarch/java"]
129
+ } else {
130
+ java.srcDirs += ["src/oldarch/java"]
131
+ }
132
+ }
133
+ }
134
+ }
135
+
136
+ repositories {
137
+ mavenCentral()
138
+ google()
139
+ maven { url 'https://jitpack.io' }
140
+ }
141
+
142
+ def kotlin_version = getExtOrDefault("kotlinVersion")
143
+
144
+ dependencies {
145
+ // For < 0.71 this resolves from the local maven repo; for > 0.71 the React
146
+ // Gradle plugin rewrites it to com.facebook.react:react-android:$version.
147
+ //noinspection GradleDynamicVersion
148
+ implementation "com.facebook.react:react-native:+"
149
+
150
+ // `strictly`, not a plain version -- the second half of the Kotlin 2.2.10
151
+ // workaround documented in kotlinOptions above.
152
+ //
153
+ // The SDK's POM requires kotlin-stdlib:2.2.10, and conflict resolution carries
154
+ // that onto the *host app's* compileClasspath (1.9.24 -> 2.2.10), so the app's
155
+ // own Kotlin then fails to compile even though nothing in the app touches the
156
+ // SDK. `-Xskip-metadata-version-check` cannot help there: it applies to this
157
+ // module, not to the consumer's. Pinning the stdlib back to whatever Kotlin the
158
+ // host is actually compiling with keeps the app buildable.
159
+ //
160
+ // The cost: the SDK was compiled against the 2.2.10 stdlib and now runs against
161
+ // an older one, so any stdlib API it uses that postdates the host's Kotlin
162
+ // throws NoSuchMethodError at runtime. That risk is the reason this is a
163
+ // stopgap and not a design -- it disappears with the upstream fix.
164
+ implementation("org.jetbrains.kotlin:kotlin-stdlib") {
165
+ version { strictly kotlin_version }
166
+ }
167
+
168
+ // The native AppsOnAir Push SDK, from JitPack -- the host app must have
169
+ // maven { url 'https://jitpack.io' } in its repositories. The coordinate stays
170
+ // overridable for teams pointing at a local build or a private repo -- set
171
+ // AppsonairReactNativeApppush_pushSdkCoordinate in the app's gradle.properties, or
172
+ // substitute a local project in settings.gradle:
173
+ //
174
+ // includeBuild('../appsonair-push-notification-android')
175
+ //
176
+ implementation getExtOrDefault("pushSdkCoordinate")
177
+ }
@@ -0,0 +1,15 @@
1
+ AppsonairReactNativeApppush_kotlinVersion=1.9.24
2
+ AppsonairReactNativeApppush_minSdkVersion=24
3
+ AppsonairReactNativeApppush_targetSdkVersion=34
4
+ AppsonairReactNativeApppush_compileSdkVersion=35
5
+
6
+ # minSdk 24 is inherited, not chosen: the native Push SDK requires AppsOnAir Core,
7
+ # which is minSdk 24. Lowering this here will fail the manifest merge.
8
+
9
+ # The native Push SDK coordinate, served by JitPack. The repo's git tag is
10
+ # `v0.0.2-alpha`; JitPack publishes it under both `0.0.2-alpha` and `v0.0.2-alpha`
11
+ # and reports the un-prefixed form as `latest`, which is also what the SDK's own
12
+ # README documents -- so that is the one pinned here. Overridable from the host
13
+ # app's gradle.properties so a team can point at a local build or a private repo
14
+ # without patching this file.
15
+ AppsonairReactNativeApppush_pushSdkCoordinate=com.github.apps-on-air:appsonair-android-push-notification:0.0.2-alpha
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.appsonairreactnativeapppush">
2
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>