react-native-push-signal 0.1.0

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 (91) hide show
  1. package/LICENSE +20 -0
  2. package/PushSignal.podspec +31 -0
  3. package/README.md +125 -0
  4. package/README.ru.md +125 -0
  5. package/android/CMakeLists.txt +24 -0
  6. package/android/build.gradle +115 -0
  7. package/android/src/main/AndroidManifest.xml +18 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  9. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignal.kt +44 -0
  10. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalCenter.kt +353 -0
  11. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalInitProvider.kt +34 -0
  12. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalMessagingService.kt +15 -0
  13. package/android/src/main/java/com/margelo/nitro/pushsignal/PushSignalPackage.kt +22 -0
  14. package/ios/PushSignal.swift +38 -0
  15. package/ios/PushSignalCenter.swift +430 -0
  16. package/ios/PushSignalLaunchStore.h +21 -0
  17. package/ios/PushSignalLaunchStore.m +26 -0
  18. package/lib/module/PushSignal.nitro.js +4 -0
  19. package/lib/module/PushSignal.nitro.js.map +1 -0
  20. package/lib/module/index.js +4 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/package.json +1 -0
  23. package/lib/module/pushSignal.js +19 -0
  24. package/lib/module/pushSignal.js.map +1 -0
  25. package/lib/module/pushSignal.native.js +46 -0
  26. package/lib/module/pushSignal.native.js.map +1 -0
  27. package/lib/typescript/package.json +1 -0
  28. package/lib/typescript/src/PushSignal.nitro.d.ts +33 -0
  29. package/lib/typescript/src/PushSignal.nitro.d.ts.map +1 -0
  30. package/lib/typescript/src/index.d.ts +3 -0
  31. package/lib/typescript/src/index.d.ts.map +1 -0
  32. package/lib/typescript/src/pushSignal.d.ts +8 -0
  33. package/lib/typescript/src/pushSignal.d.ts.map +1 -0
  34. package/lib/typescript/src/pushSignal.native.d.ts +8 -0
  35. package/lib/typescript/src/pushSignal.native.d.ts.map +1 -0
  36. package/nitro.json +23 -0
  37. package/nitrogen/generated/android/c++/JAndroidFirebaseConfig.hpp +70 -0
  38. package/nitrogen/generated/android/c++/JFunc_void_PushMessage.hpp +80 -0
  39. package/nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp +138 -0
  40. package/nitrogen/generated/android/c++/JHybridPushSignalSpec.hpp +68 -0
  41. package/nitrogen/generated/android/c++/JPermissionStatus.hpp +61 -0
  42. package/nitrogen/generated/android/c++/JPushCredentials.hpp +70 -0
  43. package/nitrogen/generated/android/c++/JPushEnvironment.hpp +58 -0
  44. package/nitrogen/generated/android/c++/JPushMessage.hpp +84 -0
  45. package/nitrogen/generated/android/c++/JPushPlatform.hpp +58 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/AndroidFirebaseConfig.kt +66 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/Func_void_PushMessage.kt +78 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/HybridPushSignalSpec.kt +87 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PermissionStatus.kt +24 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushCredentials.kt +61 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushEnvironment.kt +23 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushMessage.kt +66 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/PushPlatform.kt +23 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pushsignal/pushsignalOnLoad.kt +35 -0
  55. package/nitrogen/generated/android/pushsignal+autolinking.cmake +81 -0
  56. package/nitrogen/generated/android/pushsignal+autolinking.gradle +27 -0
  57. package/nitrogen/generated/android/pushsignalOnLoad.cpp +56 -0
  58. package/nitrogen/generated/android/pushsignalOnLoad.hpp +34 -0
  59. package/nitrogen/generated/ios/PushSignal+autolinking.rb +62 -0
  60. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.cpp +65 -0
  61. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Bridge.hpp +257 -0
  62. package/nitrogen/generated/ios/PushSignal-Swift-Cxx-Umbrella.hpp +66 -0
  63. package/nitrogen/generated/ios/PushSignalAutolinking.mm +33 -0
  64. package/nitrogen/generated/ios/PushSignalAutolinking.swift +26 -0
  65. package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.cpp +11 -0
  66. package/nitrogen/generated/ios/c++/HybridPushSignalSpecSwift.hpp +137 -0
  67. package/nitrogen/generated/ios/swift/AndroidFirebaseConfig.swift +96 -0
  68. package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +46 -0
  69. package/nitrogen/generated/ios/swift/Func_void_PushCredentials.swift +46 -0
  70. package/nitrogen/generated/ios/swift/Func_void_PushMessage.swift +46 -0
  71. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  72. package/nitrogen/generated/ios/swift/HybridPushSignalSpec.swift +60 -0
  73. package/nitrogen/generated/ios/swift/HybridPushSignalSpec_cxx.swift +226 -0
  74. package/nitrogen/generated/ios/swift/PermissionStatus.swift +44 -0
  75. package/nitrogen/generated/ios/swift/PushCredentials.swift +45 -0
  76. package/nitrogen/generated/ios/swift/PushEnvironment.swift +40 -0
  77. package/nitrogen/generated/ios/swift/PushMessage.swift +97 -0
  78. package/nitrogen/generated/ios/swift/PushPlatform.swift +40 -0
  79. package/nitrogen/generated/shared/c++/AndroidFirebaseConfig.hpp +96 -0
  80. package/nitrogen/generated/shared/c++/HybridPushSignalSpec.cpp +26 -0
  81. package/nitrogen/generated/shared/c++/HybridPushSignalSpec.hpp +79 -0
  82. package/nitrogen/generated/shared/c++/PermissionStatus.hpp +80 -0
  83. package/nitrogen/generated/shared/c++/PushCredentials.hpp +97 -0
  84. package/nitrogen/generated/shared/c++/PushEnvironment.hpp +76 -0
  85. package/nitrogen/generated/shared/c++/PushMessage.hpp +97 -0
  86. package/nitrogen/generated/shared/c++/PushPlatform.hpp +76 -0
  87. package/package.json +187 -0
  88. package/src/PushSignal.nitro.ts +37 -0
  89. package/src/index.tsx +16 -0
  90. package/src/pushSignal.native.tsx +67 -0
  91. package/src/pushSignal.tsx +32 -0
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// JPushPlatform.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "PushPlatform.hpp"
12
+
13
+ namespace margelo::nitro::pushsignal {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "PushPlatform" and the Kotlin enum "PushPlatform".
19
+ */
20
+ struct JPushPlatform final: public jni::JavaClass<JPushPlatform> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PushPlatform;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum PushPlatform.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ PushPlatform toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<PushPlatform>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JPushPlatform> fromCpp(PushPlatform value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case PushPlatform::IOS:
46
+ static const auto fieldIOS = clazz->getStaticField<JPushPlatform>("IOS");
47
+ return clazz->getStaticFieldValue(fieldIOS);
48
+ case PushPlatform::ANDROID:
49
+ static const auto fieldANDROID = clazz->getStaticField<JPushPlatform>("ANDROID");
50
+ return clazz->getStaticFieldValue(fieldANDROID);
51
+ default:
52
+ std::string stringValue = std::to_string(static_cast<int>(value));
53
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
54
+ }
55
+ }
56
+ };
57
+
58
+ } // namespace margelo::nitro::pushsignal
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// AndroidFirebaseConfig.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import java.util.Objects
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "AndroidFirebaseConfig".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class AndroidFirebaseConfig(
21
+ @DoNotStrip
22
+ @Keep
23
+ val projectId: String?,
24
+ @DoNotStrip
25
+ @Keep
26
+ val applicationId: String?,
27
+ @DoNotStrip
28
+ @Keep
29
+ val apiKey: String?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val gcmSenderId: String?
33
+ ) {
34
+ /* primary constructor */
35
+
36
+ override fun equals(other: Any?): Boolean {
37
+ if (this === other) return true
38
+ if (other !is AndroidFirebaseConfig) return false
39
+ return Objects.deepEquals(this.projectId, other.projectId)
40
+ && Objects.deepEquals(this.applicationId, other.applicationId)
41
+ && Objects.deepEquals(this.apiKey, other.apiKey)
42
+ && Objects.deepEquals(this.gcmSenderId, other.gcmSenderId)
43
+ }
44
+
45
+ override fun hashCode(): Int {
46
+ return arrayOf<Any?>(
47
+ projectId,
48
+ applicationId,
49
+ apiKey,
50
+ gcmSenderId
51
+ ).contentDeepHashCode()
52
+ }
53
+
54
+ companion object {
55
+ /**
56
+ * Constructor called from C++
57
+ */
58
+ @DoNotStrip
59
+ @Keep
60
+ @Suppress("unused")
61
+ @JvmStatic
62
+ private fun fromCpp(projectId: String?, applicationId: String?, apiKey: String?, gcmSenderId: String?): AndroidFirebaseConfig {
63
+ return AndroidFirebaseConfig(projectId, applicationId, apiKey, gcmSenderId)
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,78 @@
1
+ ///
2
+ /// Func_void_PushMessage.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript callback `(message: struct) => void`.
17
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
18
+ * or in Kotlin/Java (in which case it is a native callback).
19
+ */
20
+ @DoNotStrip
21
+ @Keep
22
+ @Suppress("ClassName", "RedundantUnitReturnType")
23
+ fun interface Func_void_PushMessage: (PushMessage) -> Unit {
24
+ /**
25
+ * Call the given JS callback.
26
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
27
+ */
28
+ @DoNotStrip
29
+ @Keep
30
+ override fun invoke(message: PushMessage): Unit
31
+ }
32
+
33
+ /**
34
+ * Represents the JavaScript callback `(message: struct) => void`.
35
+ * This is implemented in C++, via a `std::function<...>`.
36
+ * The callback might be coming from JS.
37
+ */
38
+ @DoNotStrip
39
+ @Keep
40
+ @Suppress(
41
+ "KotlinJniMissingFunction", "unused",
42
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
43
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
44
+ )
45
+ class Func_void_PushMessage_cxx: Func_void_PushMessage {
46
+ @DoNotStrip
47
+ @Keep
48
+ private val mHybridData: HybridData
49
+
50
+ @DoNotStrip
51
+ @Keep
52
+ private constructor(hybridData: HybridData) {
53
+ mHybridData = hybridData
54
+ }
55
+
56
+ @DoNotStrip
57
+ @Keep
58
+ override fun invoke(message: PushMessage): Unit
59
+ = invoke_cxx(message)
60
+
61
+ private external fun invoke_cxx(message: PushMessage): Unit
62
+ }
63
+
64
+ /**
65
+ * Represents the JavaScript callback `(message: struct) => void`.
66
+ * This is implemented in Java/Kotlin, via a `(PushMessage) -> Unit`.
67
+ * The callback is always coming from native.
68
+ */
69
+ @DoNotStrip
70
+ @Keep
71
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
72
+ class Func_void_PushMessage_java(private val function: (PushMessage) -> Unit): Func_void_PushMessage {
73
+ @DoNotStrip
74
+ @Keep
75
+ override fun invoke(message: PushMessage): Unit {
76
+ return this.function(message)
77
+ }
78
+ }
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// HybridPushSignalSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+ import com.margelo.nitro.core.Promise
15
+ import com.margelo.nitro.core.HybridObject
16
+
17
+ /**
18
+ * A Kotlin class representing the PushSignal HybridObject.
19
+ * Implement this abstract class to create Kotlin-based instances of PushSignal.
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress(
24
+ "KotlinJniMissingFunction", "unused",
25
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
26
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
27
+ )
28
+ abstract class HybridPushSignalSpec: HybridObject() {
29
+ // Properties
30
+
31
+
32
+ // Methods
33
+ @DoNotStrip
34
+ @Keep
35
+ abstract fun initialize(config: AndroidFirebaseConfig): Unit
36
+
37
+ @DoNotStrip
38
+ @Keep
39
+ abstract fun getPermissionStatus(): Promise<PermissionStatus>
40
+
41
+ @DoNotStrip
42
+ @Keep
43
+ abstract fun requestPermission(): Promise<PermissionStatus>
44
+
45
+ @DoNotStrip
46
+ @Keep
47
+ abstract fun getCredentials(): Promise<PushCredentials>
48
+
49
+ abstract fun setOnMessage(callback: (message: PushMessage) -> Unit): Unit
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private fun setOnMessage_cxx(callback: Func_void_PushMessage): Unit {
54
+ val __result = setOnMessage(callback)
55
+ return __result
56
+ }
57
+
58
+ abstract fun setOnNotificationPress(callback: (message: PushMessage) -> Unit): Unit
59
+
60
+ @DoNotStrip
61
+ @Keep
62
+ private fun setOnNotificationPress_cxx(callback: Func_void_PushMessage): Unit {
63
+ val __result = setOnNotificationPress(callback)
64
+ return __result
65
+ }
66
+
67
+ // Default implementation of `HybridObject.toString()`
68
+ override fun toString(): String {
69
+ return "[HybridObject PushSignal]"
70
+ }
71
+
72
+ // C++ backing class
73
+ @DoNotStrip
74
+ @Keep
75
+ protected open class CxxPart(javaPart: HybridPushSignalSpec): HybridObject.CxxPart(javaPart) {
76
+ // C++ JHybridPushSignalSpec::CxxPart::initHybrid(...)
77
+ @FastNative
78
+ external override fun initHybrid(): HybridData
79
+ }
80
+ override fun createCxxPart(): CxxPart {
81
+ return CxxPart(this)
82
+ }
83
+
84
+ companion object {
85
+ protected const val TAG = "HybridPushSignalSpec"
86
+ }
87
+ }
@@ -0,0 +1,24 @@
1
+ ///
2
+ /// PermissionStatus.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "PermissionStatus".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class PermissionStatus(@DoNotStrip @Keep val value: Int) {
19
+ AUTHORIZED(0),
20
+ DENIED(1),
21
+ NOTDETERMINED(2);
22
+
23
+ companion object
24
+ }
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// PushCredentials.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import java.util.Objects
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "PushCredentials".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class PushCredentials(
21
+ @DoNotStrip
22
+ @Keep
23
+ val platform: PushPlatform,
24
+ @DoNotStrip
25
+ @Keep
26
+ val token: String,
27
+ @DoNotStrip
28
+ @Keep
29
+ val environment: PushEnvironment?
30
+ ) {
31
+ /* primary constructor */
32
+
33
+ override fun equals(other: Any?): Boolean {
34
+ if (this === other) return true
35
+ if (other !is PushCredentials) return false
36
+ return Objects.deepEquals(this.platform, other.platform)
37
+ && Objects.deepEquals(this.token, other.token)
38
+ && Objects.deepEquals(this.environment, other.environment)
39
+ }
40
+
41
+ override fun hashCode(): Int {
42
+ return arrayOf<Any?>(
43
+ platform,
44
+ token,
45
+ environment
46
+ ).contentDeepHashCode()
47
+ }
48
+
49
+ companion object {
50
+ /**
51
+ * Constructor called from C++
52
+ */
53
+ @DoNotStrip
54
+ @Keep
55
+ @Suppress("unused")
56
+ @JvmStatic
57
+ private fun fromCpp(platform: PushPlatform, token: String, environment: PushEnvironment?): PushCredentials {
58
+ return PushCredentials(platform, token, environment)
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// PushEnvironment.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "PushEnvironment".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class PushEnvironment(@DoNotStrip @Keep val value: Int) {
19
+ SANDBOX(0),
20
+ PRODUCTION(1);
21
+
22
+ companion object
23
+ }
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// PushMessage.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import java.util.Objects
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "PushMessage".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class PushMessage(
21
+ @DoNotStrip
22
+ @Keep
23
+ val id: String?,
24
+ @DoNotStrip
25
+ @Keep
26
+ val title: String?,
27
+ @DoNotStrip
28
+ @Keep
29
+ val body: String?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val data: Map<String, String>
33
+ ) {
34
+ /* primary constructor */
35
+
36
+ override fun equals(other: Any?): Boolean {
37
+ if (this === other) return true
38
+ if (other !is PushMessage) return false
39
+ return Objects.deepEquals(this.id, other.id)
40
+ && Objects.deepEquals(this.title, other.title)
41
+ && Objects.deepEquals(this.body, other.body)
42
+ && Objects.deepEquals(this.data, other.data)
43
+ }
44
+
45
+ override fun hashCode(): Int {
46
+ return arrayOf<Any?>(
47
+ id,
48
+ title,
49
+ body,
50
+ data
51
+ ).contentDeepHashCode()
52
+ }
53
+
54
+ companion object {
55
+ /**
56
+ * Constructor called from C++
57
+ */
58
+ @DoNotStrip
59
+ @Keep
60
+ @Suppress("unused")
61
+ @JvmStatic
62
+ private fun fromCpp(id: String?, title: String?, body: String?, data: Map<String, String>): PushMessage {
63
+ return PushMessage(id, title, body, data)
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// PushPlatform.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "PushPlatform".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class PushPlatform(@DoNotStrip @Keep val value: Int) {
19
+ IOS(0),
20
+ ANDROID(1);
21
+
22
+ companion object
23
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// pushsignalOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.pushsignal
9
+
10
+ import android.util.Log
11
+
12
+ internal class pushsignalOnLoad {
13
+ companion object {
14
+ private const val TAG = "pushsignalOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "pushsignal".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading pushsignal C++ library...")
25
+ System.loadLibrary("pushsignal")
26
+ Log.i(TAG, "Successfully loaded pushsignal C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load pushsignal C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ #
2
+ # pushsignal+autolinking.cmake
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # This is a CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/pushsignal+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_PUSHSIGNAL_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ pushsignal PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/pushsignalOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridPushSignalSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridPushSignalSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ pushsignal PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ pushsignal
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ pushsignal
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ pushsignal
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// pushsignal+autolinking.gradle
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /// This is a Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/pushsignal+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 pushsignal is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// pushsignalOnLoad.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #ifndef BUILDING_PUSHSIGNAL_WITH_GENERATED_CMAKE_PROJECT
9
+ #error pushsignalOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "pushsignalOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridPushSignalSpec.hpp"
19
+ #include "JFunc_void_PushMessage.hpp"
20
+ #include <NitroModules/DefaultConstructableObject.hpp>
21
+
22
+ namespace margelo::nitro::pushsignal {
23
+
24
+ int initialize(JavaVM* vm) {
25
+ return facebook::jni::initialize(vm, []() {
26
+ ::margelo::nitro::pushsignal::registerAllNatives();
27
+ });
28
+ }
29
+
30
+ struct JHybridPushSignalSpecImpl: public jni::JavaClass<JHybridPushSignalSpecImpl, JHybridPushSignalSpec::JavaPart> {
31
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/pushsignal/PushSignal;";
32
+ static std::shared_ptr<JHybridPushSignalSpec> create() {
33
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridPushSignalSpecImpl::javaobject()>();
34
+ jni::local_ref<JHybridPushSignalSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
35
+ return javaPart->getJHybridPushSignalSpec();
36
+ }
37
+ };
38
+
39
+ void registerAllNatives() {
40
+ using namespace margelo::nitro;
41
+ using namespace margelo::nitro::pushsignal;
42
+
43
+ // Register native JNI methods
44
+ margelo::nitro::pushsignal::JHybridPushSignalSpec::CxxPart::registerNatives();
45
+ margelo::nitro::pushsignal::JFunc_void_PushMessage_cxx::registerNatives();
46
+
47
+ // Register Nitro Hybrid Objects
48
+ HybridObjectRegistry::registerHybridObjectConstructor(
49
+ "PushSignal",
50
+ []() -> std::shared_ptr<HybridObject> {
51
+ return JHybridPushSignalSpecImpl::create();
52
+ }
53
+ );
54
+ }
55
+
56
+ } // namespace margelo::nitro::pushsignal