@onekeyfe/react-native-jpush 0.0.0-stage → 6.7.0-alpha.435
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/LICENSE +21 -0
- package/README.md +23 -2
- package/ReactNativeJpush.podspec +66 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +143 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +143 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/cn/android/service/JTransitActivity.java +19 -0
- package/android/src/main/java/cn/jiguang/android/BuildConfig.java +10 -0
- package/android/src/main/java/cn/jiguang/android/IDataShare.java +190 -0
- package/android/src/main/java/cn/jiguang/api/BaseLogger.java +82 -0
- package/android/src/main/java/cn/jiguang/api/JAction.java +22 -0
- package/android/src/main/java/cn/jiguang/api/JActionExtra.java +21 -0
- package/android/src/main/java/cn/jiguang/api/JAnalyticsAction.java +11 -0
- package/android/src/main/java/cn/jiguang/api/JCoreInterface.java +228 -0
- package/android/src/main/java/cn/jiguang/api/JCoreManager.java +156 -0
- package/android/src/main/java/cn/jiguang/api/JDispatchAction.java +66 -0
- package/android/src/main/java/cn/jiguang/api/MultiSpHelper.java +114 -0
- package/android/src/main/java/cn/jiguang/api/ReportCallBack.java +9 -0
- package/android/src/main/java/cn/jiguang/api/SdkType.java +13 -0
- package/android/src/main/java/cn/jiguang/api/utils/JCollectionAuth.java +23 -0
- package/android/src/main/java/cn/jiguang/core/JCoreCrypto.java +545 -0
- package/android/src/main/java/cn/jiguang/core/JCoreStorage.java +737 -0
- package/android/src/main/java/cn/jiguang/core/JCoreTcpEngine.java +1394 -0
- package/android/src/main/java/cn/jiguang/core/JCoreWireCodec.java +1716 -0
- package/android/src/main/java/cn/jiguang/internal/ActionManager.java +63 -0
- package/android/src/main/java/cn/jiguang/internal/JConstants.java +61 -0
- package/android/src/main/java/cn/jiguang/internal/JCoreHelperAction.java +12 -0
- package/android/src/main/java/cn/jiguang/internal/JCoreInternalHelper.java +102 -0
- package/android/src/main/java/cn/jiguang/net/DefaultHostVerifier.java +40 -0
- package/android/src/main/java/cn/jiguang/net/HttpRequest.java +78 -0
- package/android/src/main/java/cn/jiguang/net/HttpResponse.java +48 -0
- package/android/src/main/java/cn/jiguang/net/HttpUtils.java +106 -0
- package/android/src/main/java/cn/jiguang/plugins/core/JCoreModule.java +91 -0
- package/android/src/main/java/cn/jiguang/plugins/core/JCorePackage.java +27 -0
- package/android/src/main/java/cn/jiguang/plugins/push/JPushModule.java +773 -0
- package/android/src/main/java/cn/jiguang/plugins/push/JPushPackage.java +25 -0
- package/android/src/main/java/cn/jiguang/plugins/push/common/JConstants.java +88 -0
- package/android/src/main/java/cn/jiguang/plugins/push/common/JLogger.java +122 -0
- package/android/src/main/java/cn/jiguang/plugins/push/helper/JPushHelper.java +710 -0
- package/android/src/main/java/cn/jiguang/plugins/push/receiver/JPushBroadcastReceiver.java +37 -0
- package/android/src/main/java/cn/jiguang/plugins/push/receiver/JPushModuleReceiver.java +264 -0
- package/android/src/main/java/cn/jiguang/plugins/service/JCoreModuleService.java +7 -0
- package/android/src/main/java/cn/jpush/android/api/BasicPushNotificationBuilder.java +83 -0
- package/android/src/main/java/cn/jpush/android/api/CallBackParams.java +50 -0
- package/android/src/main/java/cn/jpush/android/api/CmdMessage.java +33 -0
- package/android/src/main/java/cn/jpush/android/api/CustomMessage.java +28 -0
- package/android/src/main/java/cn/jpush/android/api/CustomPushNotificationBuilder.java +81 -0
- package/android/src/main/java/cn/jpush/android/api/DefaultPushNotificationBuilder.java +90 -0
- package/android/src/main/java/cn/jpush/android/api/InAppSlotParams.java +65 -0
- package/android/src/main/java/cn/jpush/android/api/InstrumentedActivity.java +17 -0
- package/android/src/main/java/cn/jpush/android/api/InstrumentedListActivity.java +17 -0
- package/android/src/main/java/cn/jpush/android/api/JPushInterface.java +488 -0
- package/android/src/main/java/cn/jpush/android/api/JPushMessage.java +121 -0
- package/android/src/main/java/cn/jpush/android/api/JThirdPlatFormInterface.java +147 -0
- package/android/src/main/java/cn/jpush/android/api/MultiActionsNotificationBuilder.java +72 -0
- package/android/src/main/java/cn/jpush/android/api/NotificationCustomButton.java +50 -0
- package/android/src/main/java/cn/jpush/android/api/NotificationMessage.java +67 -0
- package/android/src/main/java/cn/jpush/android/api/PushNotificationBuilder.java +13 -0
- package/android/src/main/java/cn/jpush/android/api/TagAliasCallback.java +8 -0
- package/android/src/main/java/cn/jpush/android/data/JPushCollectControl.java +96 -0
- package/android/src/main/java/cn/jpush/android/data/JPushConfig.java +79 -0
- package/android/src/main/java/cn/jpush/android/data/JPushConfigEx.java +41 -0
- package/android/src/main/java/cn/jpush/android/data/JPushLocalNotification.java +155 -0
- package/android/src/main/java/cn/jpush/android/helper/JCoreHelper.java +70 -0
- package/android/src/main/java/cn/jpush/android/helper/Logger.java +82 -0
- package/android/src/main/java/cn/jpush/android/local/ActionHelper.java +1198 -0
- package/android/src/main/java/cn/jpush/android/local/ActivityLifeCallBack.java +47 -0
- package/android/src/main/java/cn/jpush/android/local/JPushAction.java +67 -0
- package/android/src/main/java/cn/jpush/android/local/JPushConstants.java +34 -0
- package/android/src/main/java/cn/jpush/android/local/JPushResponse.java +26 -0
- package/android/src/main/java/cn/jpush/android/local/ProxyActivityAction.java +34 -0
- package/android/src/main/java/cn/jpush/android/service/AlarmReceiver.java +15 -0
- package/android/src/main/java/cn/jpush/android/service/BActivity.java +19 -0
- package/android/src/main/java/cn/jpush/android/service/DActivity.java +19 -0
- package/android/src/main/java/cn/jpush/android/service/DaemonService.java +17 -0
- package/android/src/main/java/cn/jpush/android/service/DataProvider.java +136 -0
- package/android/src/main/java/cn/jpush/android/service/DataShare.java +129 -0
- package/android/src/main/java/cn/jpush/android/service/DownloadProvider.java +139 -0
- package/android/src/main/java/cn/jpush/android/service/InitProvider.java +48 -0
- package/android/src/main/java/cn/jpush/android/service/JCommonService.java +79 -0
- package/android/src/main/java/cn/jpush/android/service/JNotifyActivity.java +28 -0
- package/android/src/main/java/cn/jpush/android/service/JPushMessageReceiver.java +93 -0
- package/android/src/main/java/cn/jpush/android/service/PushReceiver.java +26 -0
- package/android/src/main/java/cn/jpush/android/service/PushService.java +28 -0
- package/android/src/main/java/cn/jpush/android/service/SchedulerReceiver.java +17 -0
- package/android/src/main/java/cn/jpush/android/service/TagAliasReceiver.java +11 -0
- package/android/src/main/java/cn/jpush/android/service/WakedResultReceiver.java +24 -0
- package/android/src/main/java/cn/jpush/android/ui/FullScreenView.java +11 -0
- package/android/src/main/java/cn/jpush/android/ui/PopWinActivity.java +16 -0
- package/android/src/main/java/cn/jpush/android/ui/PushActivity.java +27 -0
- package/android/src/main/java/cn/jpush/android/ui/RoundedImageView.java +63 -0
- package/android/src/main/java/cn/jpush/android/ui/ShadowViewCard.java +56 -0
- package/android/src/main/java/cn/jpush/android/ups/ICallbackResult.java +5 -0
- package/android/src/main/java/cn/jpush/android/ups/JPushUPSManager.java +37 -0
- package/android/src/main/java/cn/jpush/android/ups/TokenResult.java +47 -0
- package/android/src/main/java/cn/jpush/android/ups/UPSRegisterCallBack.java +4 -0
- package/android/src/main/java/cn/jpush/android/ups/UPSTurnCallBack.java +4 -0
- package/android/src/main/java/cn/jpush/android/ups/UPSUnRegisterCallBack.java +4 -0
- package/android/src/main/java/com/margelo/nitro/reactnativejpush/ReactNativeJpush.kt +455 -0
- package/android/src/main/java/com/margelo/nitro/reactnativejpush/ReactNativeJpushPackage.kt +50 -0
- package/android/src/main/res/values/jpush_string.xml +7 -0
- package/android/src/main/res/values/jpush_style.xml +22 -0
- package/android/src/test/java/com/margelo/nitro/reactnativejpush/ReactNativeJpushProtocolTest.java +1016 -0
- package/ios/ReactNativeJpush.swift +522 -0
- package/ios/bridge/RCTJCoreModule.h +5 -0
- package/ios/bridge/RCTJCoreModule.m +31 -0
- package/ios/bridge/RCTJPushEventQueue.h +14 -0
- package/ios/bridge/RCTJPushEventQueue.m +23 -0
- package/ios/bridge/RCTJPushModule.h +37 -0
- package/ios/bridge/RCTJPushModule.m +1165 -0
- package/ios/include/JCOREService.h +3 -0
- package/ios/include/JGCOREAPI.h +14 -0
- package/ios/include/JGInforCollectionAuth.h +17 -0
- package/ios/include/JGInforCollectionAuthItems.h +2 -0
- package/ios/include/JGPushNotificationTrigger.h +2 -0
- package/ios/include/JPUSHService.h +359 -0
- package/ios/jcore/JCOREConfiguration.h +141 -0
- package/ios/jcore/JCOREConfiguration.m +703 -0
- package/ios/jcore/JCORECrypto.h +73 -0
- package/ios/jcore/JCORECrypto.m +649 -0
- package/ios/jcore/JCORESisResolver.h +56 -0
- package/ios/jcore/JCORESisResolver.m +525 -0
- package/ios/jcore/JCORETcpSession.h +42 -0
- package/ios/jcore/JCORETcpSession.m +956 -0
- package/ios/jcore/JCOREWireProtocol.h +274 -0
- package/ios/jcore/JCOREWireProtocol.m +1453 -0
- package/ios/jpush/JPUSHModels.m +214 -0
- package/ios/jpush/JPUSHNotificationManager.h +34 -0
- package/ios/jpush/JPUSHNotificationManager.m +360 -0
- package/ios/jpush/JPUSHService.m +794 -0
- package/ios/tests/ReactNativeJpushTests.m +148 -0
- package/lib/module/ReactNativeJpush.nitro.js +4 -0
- package/lib/module/ReactNativeJpush.nitro.js.map +1 -0
- package/lib/module/index.js +801 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ReactNativeJpush.nitro.d.ts +60 -0
- package/lib/typescript/src/ReactNativeJpush.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +235 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeJpushSpec.cpp +310 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeJpushSpec.hpp +115 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/Func_void_bool.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/Func_void_std__string_std__string.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/HybridReactNativeJpushSpec.kt +274 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/reactnativejpushOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativejpush+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativejpush+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativejpushOnLoad.cpp +58 -0
- package/nitrogen/generated/android/reactnativejpushOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/ReactNativeJpush+autolinking.rb +62 -0
- package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Bridge.hpp +147 -0
- package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Umbrella.hpp +46 -0
- package/nitrogen/generated/ios/ReactNativeJpushAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeJpushAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeJpushSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeJpushSpecSwift.hpp +402 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeJpushSpec.swift +107 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeJpushSpec_cxx.swift +723 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeJpushSpec.cpp +73 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeJpushSpec.hpp +116 -0
- package/package.json +173 -4
- package/src/ReactNativeJpush.nitro.ts +93 -0
- package/src/index.tsx +1090 -0
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import UserNotifications
|
|
4
|
+
import NitroModules
|
|
5
|
+
import ReactNativeNativeLogger
|
|
6
|
+
|
|
7
|
+
class ReactNativeJpush: HybridReactNativeJpushSpec {
|
|
8
|
+
private static let logTag = "RN-JPush"
|
|
9
|
+
private var localLogEnabled: Bool = false
|
|
10
|
+
private let listenerLock = NSLock()
|
|
11
|
+
private var registeredListenerIds = Set<Int>()
|
|
12
|
+
|
|
13
|
+
deinit {
|
|
14
|
+
listenerLock.lock()
|
|
15
|
+
let ids = registeredListenerIds
|
|
16
|
+
registeredListenerIds.removeAll()
|
|
17
|
+
listenerLock.unlock()
|
|
18
|
+
for id in ids {
|
|
19
|
+
RCTJPushModule.unregisterNitroEventListener(id)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func setDebugMode(enable: Bool) throws {
|
|
24
|
+
if enable {
|
|
25
|
+
JPUSHService.setDebugMode()
|
|
26
|
+
} else {
|
|
27
|
+
JPUSHService.setLogOFF()
|
|
28
|
+
}
|
|
29
|
+
OneKeyLog.info(Self.logTag, "setDebugMode enable=\(enable)")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func initPush() throws {
|
|
33
|
+
OneKeyLog.info(Self.logTag, "initPush")
|
|
34
|
+
RCTJPushModule.setupOrRefreshJPushNativeState()
|
|
35
|
+
let config = JCOREConfiguration.shared()
|
|
36
|
+
if let appKey = config.appKey, !appKey.isEmpty {
|
|
37
|
+
JPUSHService.setup(
|
|
38
|
+
withOption: nil,
|
|
39
|
+
appKey: appKey,
|
|
40
|
+
channel: config.channel,
|
|
41
|
+
apsForProduction: config.isProduction
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
RCTJPushModule.flushQueuedNotifications()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func setupWithConfig(appKey: String, channel: String, production: Bool) throws {
|
|
48
|
+
let resolvedChannel = channel.isEmpty ? "dev" : channel
|
|
49
|
+
OneKeyLog.info(Self.logTag, "setupWithConfig channel=\(resolvedChannel) production=\(production)")
|
|
50
|
+
RCTJPushModule.setupOrRefreshJPushNativeState()
|
|
51
|
+
if !appKey.isEmpty {
|
|
52
|
+
JPUSHService.setup(
|
|
53
|
+
withOption: nil,
|
|
54
|
+
appKey: appKey,
|
|
55
|
+
channel: resolvedChannel,
|
|
56
|
+
apsForProduction: production
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
RCTJPushModule.flushQueuedNotifications()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
func loadJS() throws {
|
|
63
|
+
RCTJPushModule.flushQueuedNotifications()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func stopPush() throws {
|
|
67
|
+
OneKeyLog.info(Self.logTag, "stopPush")
|
|
68
|
+
JPUSHService.turnOFFPush()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
func resumePush() throws {
|
|
72
|
+
OneKeyLog.info(Self.logTag, "resumePush")
|
|
73
|
+
JPUSHService.turnOnPush()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
func isPushStopped() throws -> Bool {
|
|
77
|
+
return JCOREConfiguration.shared().pushStopped
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
func getRegistrationID() throws -> String {
|
|
81
|
+
return JPUSHService.registrationID() ?? ""
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func isNotificationEnabled(callback: @escaping (_ enabled: Bool) -> Void) throws {
|
|
85
|
+
JPUSHNotificationManager.shared().getAuthorizationStatus { status in
|
|
86
|
+
let enabled = status.rawValue > JPAuthorizationStatus.statusDenied.rawValue
|
|
87
|
+
callback(enabled)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
func addTags(sequence: Double, tags: [String]) throws {
|
|
92
|
+
let seq = Int(sequence)
|
|
93
|
+
let tagSet = Set(tags)
|
|
94
|
+
JPUSHService.addTags(tagSet, completion: { resCode, iTags, resSeq in
|
|
95
|
+
OneKeyLog.info(Self.logTag, "onTagOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
96
|
+
let tagArray = (iTags as? Set<String>).map { Array($0) } ?? tags
|
|
97
|
+
RCTJPushModule.emitEvent(
|
|
98
|
+
withName: "TagAliasEvent",
|
|
99
|
+
payload: [
|
|
100
|
+
"code": resCode,
|
|
101
|
+
"sequence": resSeq,
|
|
102
|
+
"tags": tagArray
|
|
103
|
+
]
|
|
104
|
+
)
|
|
105
|
+
}, seq: seq)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
func setTags(sequence: Double, tags: [String]) throws {
|
|
109
|
+
let seq = Int(sequence)
|
|
110
|
+
let tagSet = Set(tags)
|
|
111
|
+
JPUSHService.setTags(tagSet, completion: { resCode, iTags, resSeq in
|
|
112
|
+
OneKeyLog.info(Self.logTag, "onTagOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
113
|
+
let tagArray = (iTags as? Set<String>).map { Array($0) } ?? tags
|
|
114
|
+
RCTJPushModule.emitEvent(
|
|
115
|
+
withName: "TagAliasEvent",
|
|
116
|
+
payload: [
|
|
117
|
+
"code": resCode,
|
|
118
|
+
"sequence": resSeq,
|
|
119
|
+
"tags": tagArray
|
|
120
|
+
]
|
|
121
|
+
)
|
|
122
|
+
}, seq: seq)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
func deleteTags(sequence: Double, tags: [String]) throws {
|
|
126
|
+
let seq = Int(sequence)
|
|
127
|
+
let tagSet = Set(tags)
|
|
128
|
+
JPUSHService.deleteTags(tagSet, completion: { resCode, iTags, resSeq in
|
|
129
|
+
OneKeyLog.info(Self.logTag, "onTagOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
130
|
+
let tagArray = (iTags as? Set<String>).map { Array($0) } ?? []
|
|
131
|
+
RCTJPushModule.emitEvent(
|
|
132
|
+
withName: "TagAliasEvent",
|
|
133
|
+
payload: [
|
|
134
|
+
"code": resCode,
|
|
135
|
+
"sequence": resSeq,
|
|
136
|
+
"tags": tagArray
|
|
137
|
+
]
|
|
138
|
+
)
|
|
139
|
+
}, seq: seq)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
func cleanTags(sequence: Double) throws {
|
|
143
|
+
let seq = Int(sequence)
|
|
144
|
+
JPUSHService.cleanTags({ resCode, _, resSeq in
|
|
145
|
+
OneKeyLog.info(Self.logTag, "onTagOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
146
|
+
RCTJPushModule.emitEvent(
|
|
147
|
+
withName: "TagAliasEvent",
|
|
148
|
+
payload: [
|
|
149
|
+
"code": resCode,
|
|
150
|
+
"sequence": resSeq
|
|
151
|
+
]
|
|
152
|
+
)
|
|
153
|
+
}, seq: seq)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
func getAllTags(sequence: Double) throws {
|
|
157
|
+
let seq = Int(sequence)
|
|
158
|
+
JPUSHService.getAllTags({ resCode, iTags, resSeq in
|
|
159
|
+
OneKeyLog.info(Self.logTag, "onTagOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
160
|
+
let tagArray = (iTags as? Set<String>).map { Array($0) } ?? []
|
|
161
|
+
RCTJPushModule.emitEvent(
|
|
162
|
+
withName: "TagAliasEvent",
|
|
163
|
+
payload: [
|
|
164
|
+
"code": resCode,
|
|
165
|
+
"sequence": resSeq,
|
|
166
|
+
"tags": tagArray
|
|
167
|
+
]
|
|
168
|
+
)
|
|
169
|
+
}, seq: seq)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
func checkTagBindState(sequence: Double, tag: String) throws {
|
|
173
|
+
let seq = Int(sequence)
|
|
174
|
+
JPUSHService.validTag(tag, completion: { resCode, _, resSeq, isBind in
|
|
175
|
+
OneKeyLog.info(Self.logTag, "onCheckTagOperatorResult seq=\(resSeq) code=\(resCode) tagEnable=\(isBind)")
|
|
176
|
+
RCTJPushModule.emitEvent(
|
|
177
|
+
withName: "TagAliasEvent",
|
|
178
|
+
payload: [
|
|
179
|
+
"code": resCode,
|
|
180
|
+
"sequence": resSeq,
|
|
181
|
+
"tag": tag,
|
|
182
|
+
"tagEnable": isBind
|
|
183
|
+
]
|
|
184
|
+
)
|
|
185
|
+
}, seq: seq)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
func setAlias(sequence: Double, alias: String) throws {
|
|
189
|
+
let seq = Int(sequence)
|
|
190
|
+
JPUSHService.setAlias(alias, completion: { resCode, iAlias, resSeq in
|
|
191
|
+
OneKeyLog.info(Self.logTag, "onAliasOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
192
|
+
RCTJPushModule.emitEvent(
|
|
193
|
+
withName: "TagAliasEvent",
|
|
194
|
+
payload: [
|
|
195
|
+
"code": resCode,
|
|
196
|
+
"sequence": resSeq,
|
|
197
|
+
"alias": iAlias ?? alias
|
|
198
|
+
]
|
|
199
|
+
)
|
|
200
|
+
}, seq: seq)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
func deleteAlias(sequence: Double) throws {
|
|
204
|
+
let seq = Int(sequence)
|
|
205
|
+
JPUSHService.deleteAlias({ resCode, _, resSeq in
|
|
206
|
+
OneKeyLog.info(Self.logTag, "onAliasOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
207
|
+
RCTJPushModule.emitEvent(
|
|
208
|
+
withName: "TagAliasEvent",
|
|
209
|
+
payload: [
|
|
210
|
+
"code": resCode,
|
|
211
|
+
"sequence": resSeq
|
|
212
|
+
]
|
|
213
|
+
)
|
|
214
|
+
}, seq: seq)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
func getAlias(sequence: Double) throws {
|
|
218
|
+
let seq = Int(sequence)
|
|
219
|
+
JPUSHService.getAlias({ resCode, iAlias, resSeq in
|
|
220
|
+
OneKeyLog.info(Self.logTag, "onAliasOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
221
|
+
RCTJPushModule.emitEvent(
|
|
222
|
+
withName: "TagAliasEvent",
|
|
223
|
+
payload: [
|
|
224
|
+
"code": resCode,
|
|
225
|
+
"sequence": resSeq,
|
|
226
|
+
"alias": iAlias ?? ""
|
|
227
|
+
]
|
|
228
|
+
)
|
|
229
|
+
}, seq: seq)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
func setProperties(sequence: Double, propertiesJson: String) throws {
|
|
233
|
+
let seq = Int(sequence)
|
|
234
|
+
guard let data = propertiesJson.data(using: .utf8),
|
|
235
|
+
let dict = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any] else {
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
JPUSHService.setProperties(dict, completion: { resCode, props, resSeq in
|
|
239
|
+
OneKeyLog.info(Self.logTag, "onPropertyOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
240
|
+
RCTJPushModule.emitEvent(
|
|
241
|
+
withName: "TagAliasEvent",
|
|
242
|
+
payload: [
|
|
243
|
+
"code": resCode,
|
|
244
|
+
"sequence": resSeq,
|
|
245
|
+
"pros": props ?? dict
|
|
246
|
+
]
|
|
247
|
+
)
|
|
248
|
+
}, seq: seq)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
func deleteProperties(sequence: Double, keys: [String]) throws {
|
|
252
|
+
let seq = Int(sequence)
|
|
253
|
+
let keySet = Set(keys)
|
|
254
|
+
JPUSHService.deleteProperties(keySet, completion: { resCode, props, resSeq in
|
|
255
|
+
OneKeyLog.info(Self.logTag, "onPropertyOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
256
|
+
RCTJPushModule.emitEvent(
|
|
257
|
+
withName: "TagAliasEvent",
|
|
258
|
+
payload: [
|
|
259
|
+
"code": resCode,
|
|
260
|
+
"sequence": resSeq,
|
|
261
|
+
"pros": props ?? [:]
|
|
262
|
+
]
|
|
263
|
+
)
|
|
264
|
+
}, seq: seq)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
func cleanProperties(sequence: Double) throws {
|
|
268
|
+
let seq = Int(sequence)
|
|
269
|
+
JPUSHService.cleanProperties({ resCode, props, resSeq in
|
|
270
|
+
OneKeyLog.info(Self.logTag, "onPropertyOperatorResult seq=\(resSeq) code=\(resCode)")
|
|
271
|
+
RCTJPushModule.emitEvent(
|
|
272
|
+
withName: "TagAliasEvent",
|
|
273
|
+
payload: [
|
|
274
|
+
"code": resCode,
|
|
275
|
+
"sequence": resSeq,
|
|
276
|
+
"pros": props ?? [:]
|
|
277
|
+
]
|
|
278
|
+
)
|
|
279
|
+
}, seq: seq)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
func setBadge(badge: Double, appBadge: Double) throws {
|
|
283
|
+
let badgeInt = Int(badge)
|
|
284
|
+
let appBadgeInt = Int(appBadge)
|
|
285
|
+
if badgeInt >= 0 {
|
|
286
|
+
_ = JPUSHService.setBadge(badgeInt)
|
|
287
|
+
}
|
|
288
|
+
if appBadgeInt >= 0 {
|
|
289
|
+
DispatchQueue.main.async {
|
|
290
|
+
UIApplication.shared.applicationIconBadgeNumber = appBadgeInt
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
func setMobileNumber(sequence: Double, mobileNumber: String) throws {
|
|
296
|
+
let seq = Int(sequence)
|
|
297
|
+
JPUSHService.setMobileNumber(mobileNumber) { error in
|
|
298
|
+
let code = (error as NSError?)?.code ?? 0
|
|
299
|
+
OneKeyLog.info(Self.logTag, "onMobileNumberOperatorResult seq=\(seq) code=\(code)")
|
|
300
|
+
RCTJPushModule.emitEvent(
|
|
301
|
+
withName: "MobileNumberEvent",
|
|
302
|
+
payload: [
|
|
303
|
+
"code": code,
|
|
304
|
+
"sequence": seq
|
|
305
|
+
]
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
func initCrashHandler() throws {
|
|
311
|
+
JPUSHService.crashLogON()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
func setPowerSaveMode(enable: Bool) throws {
|
|
315
|
+
// Android-only; no-op on iOS
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
func addLocalNotification(
|
|
319
|
+
messageID: String,
|
|
320
|
+
title: String,
|
|
321
|
+
content: String,
|
|
322
|
+
broadcastTime: String,
|
|
323
|
+
extrasJson: String
|
|
324
|
+
) throws {
|
|
325
|
+
let notifContent = JPushNotificationContent()
|
|
326
|
+
notifContent.title = title
|
|
327
|
+
notifContent.body = content
|
|
328
|
+
if #available(iOS 15.0, *) {
|
|
329
|
+
notifContent.interruptionLevel = 1
|
|
330
|
+
}
|
|
331
|
+
var userInfo: [String: Any] = [
|
|
332
|
+
"messageID": messageID,
|
|
333
|
+
"title": title,
|
|
334
|
+
"content": content
|
|
335
|
+
]
|
|
336
|
+
if let data = extrasJson.data(using: .utf8),
|
|
337
|
+
let extras = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any],
|
|
338
|
+
!extras.isEmpty {
|
|
339
|
+
userInfo["extras"] = extras
|
|
340
|
+
}
|
|
341
|
+
notifContent.userInfo = userInfo
|
|
342
|
+
|
|
343
|
+
let trigger = JPushNotificationTrigger()
|
|
344
|
+
var interval: TimeInterval = 1.0
|
|
345
|
+
if let rawSec = Double(broadcastTime), rawSec > 0 {
|
|
346
|
+
interval = rawSec > 1_000_000_000_000.0 ? (rawSec / 1000.0 - Date().timeIntervalSince1970) : rawSec
|
|
347
|
+
}
|
|
348
|
+
trigger.timeInterval = max(1.0, interval)
|
|
349
|
+
|
|
350
|
+
let request = JPushNotificationRequest()
|
|
351
|
+
request.requestIdentifier = messageID
|
|
352
|
+
request.content = notifContent
|
|
353
|
+
request.trigger = trigger
|
|
354
|
+
JPUSHService.addNotification(request)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
func removeLocalNotification(messageID: String) throws {
|
|
358
|
+
guard !messageID.isEmpty else { return }
|
|
359
|
+
let pendingIdentifier = JPushNotificationIdentifier()
|
|
360
|
+
pendingIdentifier.identifiers = [messageID]
|
|
361
|
+
pendingIdentifier.delivered = false
|
|
362
|
+
JPUSHService.removeNotification(pendingIdentifier)
|
|
363
|
+
|
|
364
|
+
let deliveredIdentifier = JPushNotificationIdentifier()
|
|
365
|
+
deliveredIdentifier.identifiers = [messageID]
|
|
366
|
+
deliveredIdentifier.delivered = true
|
|
367
|
+
JPUSHService.removeNotification(deliveredIdentifier)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
func clearLocalNotifications() throws {
|
|
371
|
+
JPUSHService.removeNotification(nil)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
func clearAllNotifications() throws {
|
|
375
|
+
JPUSHService.removeNotification(nil)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
func clearNotificationById(notificationId: Double) throws {
|
|
379
|
+
let idStr = String(Int(notificationId))
|
|
380
|
+
let pendingIdentifier = JPushNotificationIdentifier()
|
|
381
|
+
pendingIdentifier.identifiers = [idStr]
|
|
382
|
+
pendingIdentifier.delivered = false
|
|
383
|
+
JPUSHService.removeNotification(pendingIdentifier)
|
|
384
|
+
|
|
385
|
+
let deliveredIdentifier = JPushNotificationIdentifier()
|
|
386
|
+
deliveredIdentifier.identifiers = [idStr]
|
|
387
|
+
deliveredIdentifier.delivered = true
|
|
388
|
+
JPUSHService.removeNotification(deliveredIdentifier)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
func requestPermission() throws {
|
|
392
|
+
JPUSHService.requestNotificationAuthorization(nil)
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
func setPushTime(days: [Double], startHour: Double, endHour: Double) throws {
|
|
396
|
+
// Android-only; no-op on iOS
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
func setSilenceTime(
|
|
400
|
+
startHour: Double,
|
|
401
|
+
startMinute: Double,
|
|
402
|
+
endHour: Double,
|
|
403
|
+
endMinute: Double
|
|
404
|
+
) throws {
|
|
405
|
+
// Android-only; no-op on iOS
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
func setLatestNotificationNumber(maxNumber: Double) throws {
|
|
409
|
+
// Android-only; no-op on iOS
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
func setChannel(channel: String) throws {
|
|
413
|
+
if !channel.isEmpty {
|
|
414
|
+
JCOREConfiguration.shared().channel = channel
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
func setChannelAndSound(channel: String, channelId: String, sound: String) throws {
|
|
419
|
+
if !channel.isEmpty {
|
|
420
|
+
JCOREConfiguration.shared().channel = channel
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
func setLinkMergeEnable(enable: Bool) throws {
|
|
425
|
+
// Android-only; no-op on iOS
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
func setSmartPushEnable(enable: Bool) throws {
|
|
429
|
+
JPUSHService.setSmartPushEnable(enable)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
func setDataInsightsEnable(enable: Bool) throws {
|
|
433
|
+
JPUSHService.setDataInsightsEnable(enable)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
func setGeofenceEnable(enable: Bool) throws {
|
|
437
|
+
JPUSHService.setLocationEanable(enable)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
func setBackgroundEnable(enable: Bool) throws {
|
|
441
|
+
JPUSHService.setBackgroundEnable(enable)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
func setMaxGeofenceNumber(maxNumber: Double) throws {
|
|
445
|
+
JPUSHService.setGeofeneceMaxCount(Int(maxNumber))
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
func deleteGeofence(geoFenceID: String) throws {
|
|
449
|
+
JPUSHService.removeGeofence(withIdentifier: geoFenceID)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
func pageEnterTo(pageName: String) throws {
|
|
453
|
+
JPUSHService.pageEnter(to: pageName)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
func pageLeave(pageName: String) throws {
|
|
457
|
+
JPUSHService.pageLeave(pageName)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
func setCollectControl(
|
|
461
|
+
imei: Bool,
|
|
462
|
+
imsi: Bool,
|
|
463
|
+
mac: Bool,
|
|
464
|
+
wifi: Bool,
|
|
465
|
+
bssid: Bool,
|
|
466
|
+
ssid: Bool,
|
|
467
|
+
cell: Bool,
|
|
468
|
+
gps: Bool
|
|
469
|
+
) throws {
|
|
470
|
+
let control = JPushCollectControl()
|
|
471
|
+
control.bssid = bssid
|
|
472
|
+
control.ssid = ssid
|
|
473
|
+
control.cell = cell
|
|
474
|
+
control.gps = gps
|
|
475
|
+
JPUSHService.setCollectControl(control)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
func setAuth(auth: Bool) throws {
|
|
479
|
+
JGInforCollectionAuth.jCollectionAuth { authInfo in
|
|
480
|
+
authInfo.isAuth = auth
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
func setCountryCode(code: String) throws {
|
|
485
|
+
// Stored for diagnostic/config parity
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
func enableAutoWakeup(enable: Bool) throws {
|
|
489
|
+
// Android-only; no-op on iOS
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
func enableSDKLocalLog(enable: Bool, uploadJgToServer: Bool) throws {
|
|
493
|
+
localLogEnabled = enable
|
|
494
|
+
JCOREConfiguration.setLocalLogEnabled(enable)
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
func readNewLogs() throws -> String {
|
|
498
|
+
let logs = JCOREConfiguration.recentLogs().joined(separator: "\n")
|
|
499
|
+
JCOREConfiguration.clearRecentLogs()
|
|
500
|
+
return logs
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
func addEventListener(
|
|
504
|
+
callback: @escaping (_ eventName: String, _ payloadJson: String) -> Void
|
|
505
|
+
) throws -> Double {
|
|
506
|
+
let listenerId = RCTJPushModule.registerNitroEventListener { eventName, payloadJson in
|
|
507
|
+
callback(eventName, payloadJson)
|
|
508
|
+
}
|
|
509
|
+
listenerLock.lock()
|
|
510
|
+
registeredListenerIds.insert(listenerId)
|
|
511
|
+
listenerLock.unlock()
|
|
512
|
+
return Double(listenerId)
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
func removeEventListener(id: Double) throws {
|
|
516
|
+
let listenerId = Int(id)
|
|
517
|
+
listenerLock.lock()
|
|
518
|
+
registeredListenerIds.remove(listenerId)
|
|
519
|
+
listenerLock.unlock()
|
|
520
|
+
RCTJPushModule.unregisterNitroEventListener(listenerId)
|
|
521
|
+
}
|
|
522
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#import "RCTJCoreModule.h"
|
|
2
|
+
#import "JGInforCollectionAuth.h"
|
|
3
|
+
|
|
4
|
+
#if __has_include(<React/RCTBridge.h>)
|
|
5
|
+
#import <React/RCTBridge.h>
|
|
6
|
+
#elif __has_include("RCTBridge.h")
|
|
7
|
+
#import "RCTBridge.h"
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
@interface RCTJCoreModule () <RCTBridgeModule>
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
@implementation RCTJCoreModule
|
|
14
|
+
|
|
15
|
+
RCT_EXPORT_MODULE(JCoreModule);
|
|
16
|
+
|
|
17
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
18
|
+
return NO;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
RCT_EXPORT_METHOD(setAuth:(BOOL)enable) {
|
|
22
|
+
[JGInforCollectionAuth JCollectionAuth:^(JGInforCollectionAuthItems * _Nonnull authInfo) {
|
|
23
|
+
authInfo.isAuth = enable;
|
|
24
|
+
}];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
28
|
+
return @[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
@interface RCTJPushEventQueue : NSObject
|
|
6
|
+
|
|
7
|
+
+ (nonnull instancetype)sharedInstance;
|
|
8
|
+
|
|
9
|
+
@property (nonatomic, strong, nullable) NSMutableArray<NSDictionary *> *_notificationQueue;
|
|
10
|
+
@property (nonatomic, strong, nullable) NSMutableArray<NSDictionary *> *_localNotificationQueue;
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#import "RCTJPushEventQueue.h"
|
|
2
|
+
|
|
3
|
+
@implementation RCTJPushEventQueue
|
|
4
|
+
|
|
5
|
+
+ (instancetype)sharedInstance {
|
|
6
|
+
static RCTJPushEventQueue *instance = nil;
|
|
7
|
+
static dispatch_once_t onceToken;
|
|
8
|
+
dispatch_once(&onceToken, ^{
|
|
9
|
+
instance = [[self alloc] init];
|
|
10
|
+
});
|
|
11
|
+
return instance;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
- (instancetype)init {
|
|
15
|
+
self = [super init];
|
|
16
|
+
if (self) {
|
|
17
|
+
self._notificationQueue = [NSMutableArray array];
|
|
18
|
+
self._localNotificationQueue = [NSMutableArray array];
|
|
19
|
+
}
|
|
20
|
+
return self;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#if __has_include("JPUSHService.h")
|
|
4
|
+
#import "JPUSHService.h"
|
|
5
|
+
#elif __has_include("../include/JPUSHService.h")
|
|
6
|
+
#import "../include/JPUSHService.h"
|
|
7
|
+
#endif
|
|
8
|
+
#import "RCTJPushEventQueue.h"
|
|
9
|
+
|
|
10
|
+
#define J_APNS_NOTIFICATION_ARRIVED_EVENT @"J_APNS_NOTIFICATION_ARRIVED_EVENT"
|
|
11
|
+
#define J_APNS_NOTIFICATION_OPENED_EVENT @"J_APNS_NOTIFICATION_OPENED_EVENT"
|
|
12
|
+
#define J_LOCAL_NOTIFICATION_ARRIVED_EVENT @"J_LOCAL_NOTIFICATION_ARRIVED_EVENT"
|
|
13
|
+
#define J_LOCAL_NOTIFICATION_OPENED_EVENT @"J_LOCAL_NOTIFICATION_OPENED_EVENT"
|
|
14
|
+
#define J_CUSTOM_NOTIFICATION_EVENT @"J_CUSTOM_NOTIFICATION_EVENT"
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
17
|
+
|
|
18
|
+
typedef void (^RCTJPushNitroEventListener)(NSString *eventName, NSString *payloadJson);
|
|
19
|
+
|
|
20
|
+
@interface RCTJPushModule : NSObject
|
|
21
|
+
|
|
22
|
+
+ (nullable instancetype)sharedModule;
|
|
23
|
+
+ (NSArray<RCTJPushModule *> *)allActiveModules;
|
|
24
|
+
+ (void)clearActiveModules;
|
|
25
|
+
+ (void)ensureSharedNativeObservers;
|
|
26
|
+
+ (void)setupOrRefreshJPushNativeState;
|
|
27
|
+
+ (NSInteger)registerNitroEventListener:(RCTJPushNitroEventListener)listener;
|
|
28
|
+
+ (void)unregisterNitroEventListener:(NSInteger)listenerId;
|
|
29
|
+
+ (void)emitEventWithName:(NSString *)eventName payload:(NSDictionary *)payload;
|
|
30
|
+
+ (void)flushPendingBridgeEvents;
|
|
31
|
+
+ (void)flushQueuedNotifications;
|
|
32
|
+
- (BOOL)emitToDeviceEventEmitter:(NSString *)eventName payload:(NSDictionary *)payload;
|
|
33
|
+
- (void)setupOrRefreshJPushNativeState;
|
|
34
|
+
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|