@patra-cid/akaim-sdk-rn 0.4.16-denymsg.3
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/AkaimSdkRn.podspec +96 -0
- package/LICENSE +20 -0
- package/README.md +109 -0
- package/android/build.gradle +86 -0
- package/android/gradle.properties +8 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/akaimsdkrn/AkaimSdkRnModule.kt +1327 -0
- package/android/src/main/java/com/akaimsdkrn/AkaimSdkRnPackage.kt +33 -0
- package/android/src/main/java/com/akaimsdkrn/CallbackPromise.kt +27 -0
- package/android/src/main/java/com/akaimsdkrn/SendMsgCallBack.kt +32 -0
- package/android/src/main/java/com/akaimsdkrn/listener/AdvancedMsgListener.kt +36 -0
- package/android/src/main/java/com/akaimsdkrn/listener/BatchMsgListener.kt +16 -0
- package/android/src/main/java/com/akaimsdkrn/listener/InitSDKListener.kt +39 -0
- package/android/src/main/java/com/akaimsdkrn/listener/OnConversationListener.kt +40 -0
- package/android/src/main/java/com/akaimsdkrn/listener/OnFriendshipListener.kt +53 -0
- package/android/src/main/java/com/akaimsdkrn/listener/OnGroupListener.kt +52 -0
- package/android/src/main/java/com/akaimsdkrn/listener/SetCustomBusinessListener.kt +12 -0
- package/android/src/main/java/com/akaimsdkrn/listener/UploadFileCallbackListener.kt +52 -0
- package/android/src/main/java/com/akaimsdkrn/listener/UploadLogProgressListener.kt +20 -0
- package/android/src/main/java/com/akaimsdkrn/listener/UserListener.kt +28 -0
- package/android/src/main/java/com/akaimsdkrn/utils/Emitter.kt +78 -0
- package/ios/AkaimSdkRn.h +17 -0
- package/ios/AkaimSdkRn.mm +1622 -0
- package/ios/CallbackPromise.h +19 -0
- package/ios/CallbackPromise.mm +58 -0
- package/ios/CodeGenStructHelper.h +17 -0
- package/ios/ReactLazyVectorConverter.h +22 -0
- package/ios/SendMessageCallback.h +22 -0
- package/ios/SendMessageCallback.mm +67 -0
- package/ios/UploadFileCallback.h +21 -0
- package/ios/UploadFileCallback.mm +80 -0
- package/ios/UploadLogCallback.h +22 -0
- package/ios/UploadLogCallback.mm +44 -0
- package/lib/module/NativeAkaimSdkRn.js +153 -0
- package/lib/module/NativeAkaimSdkRn.js.map +1 -0
- package/lib/module/index.js +361 -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/NativeAkaimSdkRn.d.ts +947 -0
- package/lib/typescript/src/NativeAkaimSdkRn.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +118 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +171 -0
- package/src/NativeAkaimSdkRn.ts +1177 -0
- package/src/index.tsx +758 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.akaimsdkrn
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class AkaimSdkRnPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == AkaimSdkRnModule.NAME) {
|
|
13
|
+
AkaimSdkRnModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[AkaimSdkRnModule.NAME] = ReactModuleInfo(
|
|
23
|
+
AkaimSdkRnModule.NAME,
|
|
24
|
+
AkaimSdkRnModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.akaimsdkrn
|
|
2
|
+
|
|
3
|
+
import com.alibaba.fastjson.JSON
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import aka_im_callback.Base
|
|
6
|
+
import com.akaimsdkrn.utils.Emitter
|
|
7
|
+
|
|
8
|
+
class CallbackPromise(private val promise: Promise) : Base {
|
|
9
|
+
|
|
10
|
+
private val emitter = Emitter()
|
|
11
|
+
|
|
12
|
+
override fun onError(errorCode: Int, errorMsg: String) {
|
|
13
|
+
promise.reject(errorCode.toString(), errorMsg)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun onSuccess(s: String) {
|
|
17
|
+
try {
|
|
18
|
+
promise.resolve(emitter.convertJsonToMap(JSON.parseObject(s)))
|
|
19
|
+
} catch (e1: Exception) {
|
|
20
|
+
try {
|
|
21
|
+
promise.resolve(emitter.convertJsonToArray(JSON.parseArray(s)))
|
|
22
|
+
} catch (e2: Exception) {
|
|
23
|
+
promise.resolve(s)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.akaimsdkrn
|
|
2
|
+
|
|
3
|
+
import com.alibaba.fastjson.JSON
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.akaimsdkrn.utils.Emitter
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import aka_im_callback.SendMsgCallBack
|
|
11
|
+
|
|
12
|
+
class SendMsgCallBack(
|
|
13
|
+
private val ctx: ReactApplicationContext,
|
|
14
|
+
private val promise: Promise,
|
|
15
|
+
private val message: ReadableMap
|
|
16
|
+
) : Emitter(), SendMsgCallBack {
|
|
17
|
+
|
|
18
|
+
override fun onError(errCode: Int, errString: String) {
|
|
19
|
+
promise.reject(errCode.toString(), errString)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun onProgress(progress: Long) {
|
|
23
|
+
val params = Arguments.createMap()
|
|
24
|
+
params.putInt("progress", progress.toInt())
|
|
25
|
+
params.putMap("message", Arguments.makeNativeMap(message.toHashMap()))
|
|
26
|
+
send(ctx, "SendMessageProgress", params)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun onSuccess(s: String) {
|
|
30
|
+
promise.resolve(convertJsonToMap(JSON.parseObject(s)))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnAdvancedMsgListener
|
|
6
|
+
|
|
7
|
+
class AdvancedMsgListener(private val ctx: ReactApplicationContext) : Emitter(), OnAdvancedMsgListener {
|
|
8
|
+
|
|
9
|
+
override fun onMsgDeleted(s: String) {
|
|
10
|
+
send(ctx, "onMsgDeleted", jsonStringToMap(s))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun onNewRecvMessageRevoked(s: String) {
|
|
14
|
+
send(ctx, "onNewRecvMessageRevoked", jsonStringToMap(s))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun onRecvC2CReadReceipt(s: String) {
|
|
18
|
+
send(ctx, "onRecvC2CReadReceipt", jsonStringToArray(s))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun onRecvNewMessage(s: String) {
|
|
22
|
+
send(ctx, "onRecvNewMessage", jsonStringToMap(s))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun onMsgContentChanged(s: String) {
|
|
26
|
+
send(ctx, "onMsgContentChanged", jsonStringToMap(s))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun onRecvOfflineNewMessage(s: String) {
|
|
30
|
+
send(ctx, "onRecvOfflineNewMessage", jsonStringToMap(s))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun onRecvOnlineOnlyMessage(s: String) {
|
|
34
|
+
send(ctx, "onRecvOnlineOnlyMessage", jsonStringToMap(s))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnBatchMsgListener
|
|
6
|
+
|
|
7
|
+
class BatchMsgListener(private val ctx: ReactApplicationContext) : Emitter(), OnBatchMsgListener {
|
|
8
|
+
|
|
9
|
+
override fun onRecvNewMessages(s: String) {
|
|
10
|
+
send(ctx, "onRecvNewMessages", jsonStringToArray(s))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun onRecvOfflineNewMessages(s: String) {
|
|
14
|
+
send(ctx, "onRecvOfflineNewMessages", jsonStringToArray(s))
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
8
|
+
import com.akaimsdkrn.utils.Emitter
|
|
9
|
+
import aka_im_callback.OnConnListener
|
|
10
|
+
|
|
11
|
+
class InitSDKListener(private val ctx: ReactApplicationContext) : Emitter(), OnConnListener {
|
|
12
|
+
|
|
13
|
+
override fun onConnectFailed(errCode: Int, errMsg: String) {
|
|
14
|
+
val params = Arguments.createMap()
|
|
15
|
+
params.putInt("errCode", errCode)
|
|
16
|
+
params.putString("errMsg", errMsg)
|
|
17
|
+
send(ctx, "onConnectFailed", params)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun onConnectSuccess() {
|
|
21
|
+
send(ctx, "onConnectSuccess", null)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun onConnecting() {
|
|
25
|
+
send(ctx, "onConnecting", null)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun onKickedOffline() {
|
|
29
|
+
send(ctx, "onKickedOffline", null)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override fun onUserTokenExpired() {
|
|
33
|
+
send(ctx, "onUserTokenExpired", null)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun onUserTokenInvalid(s: String) {
|
|
37
|
+
send(ctx, "onUserTokenInvalid", null)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnConversationListener
|
|
6
|
+
|
|
7
|
+
class OnConversationListener(private val ctx: ReactApplicationContext) : Emitter(), OnConversationListener {
|
|
8
|
+
|
|
9
|
+
override fun onConversationChanged(s: String) {
|
|
10
|
+
send(ctx, "onConversationChanged", jsonStringToArray(s))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun onConversationUserInputStatusChanged(s: String) {
|
|
14
|
+
send(ctx, "onInputStatusChanged", jsonStringToMap(s))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun onNewConversation(s: String) {
|
|
18
|
+
send(ctx, "onNewConversation", jsonStringToArray(s))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun onSyncServerFailed(b: Boolean) {
|
|
22
|
+
send(ctx, "onSyncServerFailed", b)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun onSyncServerFinish(b: Boolean) {
|
|
26
|
+
send(ctx, "onSyncServerFinish", b)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun onSyncServerStart(b: Boolean) {
|
|
30
|
+
send(ctx, "onSyncServerStart", b)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun onSyncServerProgress(l: Long) {
|
|
34
|
+
send(ctx, "onSyncServerProgress", l.toInt())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun onTotalUnreadMessageCountChanged(i: Int) {
|
|
38
|
+
send(ctx, "onTotalUnreadMessageCountChanged", i)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnFriendshipListener
|
|
6
|
+
|
|
7
|
+
class OnFriendshipListener(private val ctx: ReactApplicationContext) : Emitter(), OnFriendshipListener {
|
|
8
|
+
|
|
9
|
+
override fun onBlackAdded(s: String) {
|
|
10
|
+
send(ctx, "onBlackAdded", jsonStringToMap(s))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun onBlackDeleted(s: String) {
|
|
14
|
+
send(ctx, "onBlackDeleted", jsonStringToMap(s))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
override fun onBlackAddedByOther(s: String) {
|
|
19
|
+
send(ctx, "onBlackAddedByOther", jsonStringToMap(s))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun onBlackDeletedByOther(s: String) {
|
|
23
|
+
send(ctx, "onBlackDeletedByOther", jsonStringToMap(s))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun onFriendAdded(s: String) {
|
|
27
|
+
send(ctx, "onFriendAdded", jsonStringToMap(s))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun onFriendApplicationAccepted(s: String) {
|
|
31
|
+
send(ctx, "onFriendApplicationAccepted", jsonStringToMap(s))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun onFriendApplicationAdded(s: String) {
|
|
35
|
+
send(ctx, "onFriendApplicationAdded", jsonStringToMap(s))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun onFriendApplicationDeleted(s: String) {
|
|
39
|
+
send(ctx, "onFriendApplicationDeleted", jsonStringToMap(s))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun onFriendApplicationRejected(s: String) {
|
|
43
|
+
send(ctx, "onFriendApplicationRejected", jsonStringToMap(s))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun onFriendDeleted(s: String) {
|
|
47
|
+
send(ctx, "onFriendDeleted", jsonStringToMap(s))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun onFriendInfoChanged(s: String) {
|
|
51
|
+
send(ctx, "onFriendInfoChanged", jsonStringToMap(s))
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnGroupListener
|
|
6
|
+
|
|
7
|
+
class OnGroupListener(private val ctx: ReactApplicationContext) : Emitter(), OnGroupListener {
|
|
8
|
+
|
|
9
|
+
override fun onGroupApplicationAccepted(s: String) {
|
|
10
|
+
send(ctx, "onGroupApplicationAccepted", jsonStringToMap(s))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun onGroupApplicationAdded(s: String) {
|
|
14
|
+
send(ctx, "onGroupApplicationAdded", jsonStringToMap(s))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun onGroupApplicationDeleted(s: String) {
|
|
18
|
+
send(ctx, "onGroupApplicationDeleted", jsonStringToMap(s))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun onGroupApplicationRejected(s: String) {
|
|
22
|
+
send(ctx, "onGroupApplicationRejected", jsonStringToMap(s))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun onGroupDismissed(s: String) {
|
|
26
|
+
send(ctx, "onGroupDismissed", jsonStringToMap(s))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun onGroupInfoChanged(s: String) {
|
|
30
|
+
send(ctx, "onGroupInfoChanged", jsonStringToMap(s))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun onGroupMemberAdded(s: String) {
|
|
34
|
+
send(ctx, "onGroupMemberAdded", jsonStringToMap(s))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun onGroupMemberDeleted(s: String) {
|
|
38
|
+
send(ctx, "onGroupMemberDeleted", jsonStringToMap(s))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun onGroupMemberInfoChanged(s: String) {
|
|
42
|
+
send(ctx, "onGroupMemberInfoChanged", jsonStringToMap(s))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun onJoinedGroupAdded(s: String) {
|
|
46
|
+
send(ctx, "onJoinedGroupAdded", jsonStringToMap(s))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun onJoinedGroupDeleted(s: String) {
|
|
50
|
+
send(ctx, "onJoinedGroupDeleted", jsonStringToMap(s))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnCustomBusinessListener
|
|
6
|
+
|
|
7
|
+
class SetCustomBusinessListener(private val ctx: ReactApplicationContext) : Emitter(), OnCustomBusinessListener {
|
|
8
|
+
|
|
9
|
+
override fun onRecvCustomBusinessMessage(s: String) {
|
|
10
|
+
send(ctx, "onRecvCustomBusinessMessage", jsonStringToMap(s))
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
6
|
+
import com.akaimsdkrn.utils.Emitter
|
|
7
|
+
import aka_im_callback.UploadFileCallback
|
|
8
|
+
|
|
9
|
+
class UploadFileCallbackListener(
|
|
10
|
+
private val ctx: ReactApplicationContext,
|
|
11
|
+
private val operationID: String
|
|
12
|
+
) : Emitter(), UploadFileCallback {
|
|
13
|
+
|
|
14
|
+
override fun complete(size: Long, url: String, type: Long) {
|
|
15
|
+
// 空实现
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun hashPartComplete(hash: String, partHash: String) {
|
|
19
|
+
// 空实现
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun hashPartProgress(index: Long, size: Long, partHash: String) {
|
|
23
|
+
// 空实现
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun open(size: Long) {
|
|
27
|
+
// 空实现
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun partSize(partSize: Long, num: Long) {
|
|
31
|
+
// 空实现
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun uploadComplete(fileSize: Long, streamSize: Long, storageSize: Long) {
|
|
35
|
+
val params = Arguments.createMap()
|
|
36
|
+
val data = WritableNativeMap()
|
|
37
|
+
data.putInt("fileSize", fileSize.toInt())
|
|
38
|
+
data.putInt("streamSize", streamSize.toInt())
|
|
39
|
+
data.putInt("storageSize", storageSize.toInt())
|
|
40
|
+
data.putString("operationID", operationID)
|
|
41
|
+
params.putMap("data", data)
|
|
42
|
+
send(ctx, "uploadComplete", params)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun uploadID(uploadId: String) {
|
|
46
|
+
// 空实现
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun uploadPartComplete(index: Long, partSize: Long, partHash: String) {
|
|
50
|
+
// 空实现
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.akaimsdkrn.utils.Emitter
|
|
6
|
+
import aka_im_callback.UploadLogProgress
|
|
7
|
+
|
|
8
|
+
class UploadLogProgressListener(
|
|
9
|
+
private val ctx: ReactApplicationContext,
|
|
10
|
+
private val operationID: String
|
|
11
|
+
) : Emitter(), UploadLogProgress {
|
|
12
|
+
|
|
13
|
+
override fun onProgress(current: Long, size: Long) {
|
|
14
|
+
val params = Arguments.createMap()
|
|
15
|
+
params.putInt("current", current.toInt())
|
|
16
|
+
params.putInt("size", size.toInt())
|
|
17
|
+
params.putString("operationID", operationID)
|
|
18
|
+
send(ctx, "uploadOnProgress", params)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.akaimsdkrn.listener
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.akaimsdkrn.utils.Emitter
|
|
5
|
+
import aka_im_callback.OnUserListener
|
|
6
|
+
|
|
7
|
+
class UserListener(private val ctx: ReactApplicationContext) : Emitter(), OnUserListener {
|
|
8
|
+
|
|
9
|
+
override fun onSelfInfoUpdated(s: String) {
|
|
10
|
+
send(ctx, "onSelfInfoUpdated", jsonStringToMap(s))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun onUserCommandAdd(s: String) {
|
|
14
|
+
// 空实现
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun onUserCommandDelete(s: String) {
|
|
18
|
+
// 空实现
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun onUserCommandUpdate(s: String) {
|
|
22
|
+
// 空实现
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun onUserStatusChanged(s: String) {
|
|
26
|
+
send(ctx, "onUserStatusChanged", jsonStringToMap(s))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
package com.akaimsdkrn.utils
|
|
2
|
+
|
|
3
|
+
import com.alibaba.fastjson.JSON
|
|
4
|
+
import com.alibaba.fastjson.JSONArray
|
|
5
|
+
import com.alibaba.fastjson.JSONObject
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
|
+
import com.facebook.react.bridge.ReactContext
|
|
8
|
+
import com.facebook.react.bridge.WritableArray
|
|
9
|
+
import com.facebook.react.bridge.WritableMap
|
|
10
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
11
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
12
|
+
import java.math.BigDecimal
|
|
13
|
+
|
|
14
|
+
open class Emitter {
|
|
15
|
+
|
|
16
|
+
fun send(reactContext: ReactContext, eventName: String, params: Any?) {
|
|
17
|
+
reactContext
|
|
18
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
19
|
+
.emit(eventName, params)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fun jsonStringToMap(data: String): WritableMap {
|
|
23
|
+
val parsedData = JSON.parseObject(data)
|
|
24
|
+
return convertJsonToMap(parsedData)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fun jsonStringToArray(data: String): WritableArray {
|
|
28
|
+
val parsedArray = JSON.parseArray(data)
|
|
29
|
+
val dataArray = WritableNativeArray()
|
|
30
|
+
for (item in parsedArray) {
|
|
31
|
+
dataArray.pushMap(convertJsonToMap(item as JSONObject))
|
|
32
|
+
}
|
|
33
|
+
return dataArray
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun convertJsonToMap(jsonObject: JSONObject): WritableMap {
|
|
37
|
+
val writableMap = Arguments.createMap()
|
|
38
|
+
for (key in jsonObject.keys) {
|
|
39
|
+
val value = jsonObject[key]
|
|
40
|
+
when (value) {
|
|
41
|
+
is String -> writableMap.putString(key, value)
|
|
42
|
+
is Int -> writableMap.putInt(key, value)
|
|
43
|
+
is Long -> writableMap.putDouble(key, value.toDouble())
|
|
44
|
+
is BigDecimal -> {
|
|
45
|
+
try {
|
|
46
|
+
writableMap.putInt(key, value.intValueExact())
|
|
47
|
+
} catch (e: ArithmeticException) {
|
|
48
|
+
writableMap.putDouble(key, value.toDouble())
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
is Boolean -> writableMap.putBoolean(key, value)
|
|
52
|
+
is JSONObject -> writableMap.putMap(key, convertJsonToMap(value))
|
|
53
|
+
is JSONArray -> writableMap.putArray(key, convertJsonToArray(value))
|
|
54
|
+
else -> writableMap.putNull(key)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return writableMap
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fun convertJsonToArray(jsonArray: JSONArray): WritableArray {
|
|
61
|
+
val writableArray = Arguments.createArray()
|
|
62
|
+
for (i in 0 until jsonArray.size) {
|
|
63
|
+
val item = jsonArray[i]
|
|
64
|
+
when (item) {
|
|
65
|
+
is JSONObject -> writableArray.pushMap(convertJsonToMap(item))
|
|
66
|
+
is JSONArray -> writableArray.pushArray(convertJsonToArray(item))
|
|
67
|
+
is String -> writableArray.pushString(item)
|
|
68
|
+
is Int -> writableArray.pushInt(item)
|
|
69
|
+
is Long -> writableArray.pushDouble(item.toDouble())
|
|
70
|
+
is Double -> writableArray.pushDouble(item)
|
|
71
|
+
is Boolean -> writableArray.pushBoolean(item)
|
|
72
|
+
else -> writableArray.pushNull()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return writableArray
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
package/ios/AkaimSdkRn.h
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#import <AkaimSdkRnSpec/AkaimSdkRnSpec.h>
|
|
2
|
+
|
|
3
|
+
#if __has_include("RCTTurboModule.h")
|
|
4
|
+
#import "RCTTurboModule.h"
|
|
5
|
+
#import "RCTEventEmitter.h"
|
|
6
|
+
#else
|
|
7
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
8
|
+
#import <React/RCTEventEmitter.h>
|
|
9
|
+
#endif
|
|
10
|
+
#import <AkaIMCore/AkaIMCore.h>
|
|
11
|
+
#import "CallbackPromise.h"
|
|
12
|
+
|
|
13
|
+
@interface AkaimSdkRn : RCTEventEmitter <NativeAkaimSdkRnSpec, RCTTurboModule, Aka_im_callbackOnConnListener, Aka_im_callbackOnUserListener, Aka_im_callbackOnAdvancedMsgListener, Aka_im_callbackOnFriendshipListener, Aka_im_callbackOnConversationListener, Aka_im_callbackOnGroupListener, Aka_im_callbackOnBatchMsgListener>
|
|
14
|
+
|
|
15
|
+
- (void)pushEvent:(NSString *)eventName data:(id)data;
|
|
16
|
+
|
|
17
|
+
@end
|