Skip to content

Commit 930bb20

Browse files
committed
update native ios init function
1 parent e2dde25 commit 930bb20

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

ios/RCTJMessageModule/JMessageHelper.m

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,38 @@ + (JMessageHelper *)shareInstance {
2929
-(void)initJMessage:(NSDictionary*)options{
3030
//TODO: add init jmessage
3131
// init third-party SDK
32-
// [JMessage addDelegate:self withConversation:nil];
33-
//
34-
// [JMessage setupJMessage:_launchOptions
35-
// appKey:appkey
36-
// channel:channel
37-
// apsForProduction:[isProduction boolValue]
38-
// category:nil
39-
// messageRoaming:[isOpenMessageRoaming boolValue]];
32+
33+
NSString *appkey = @"";
34+
NSString *channel = @"";
35+
BOOL isProduction = true;
36+
BOOL isOpenMessageRoaming = false;
37+
38+
if (options[@"appkey"]) {
39+
appkey = options[@"appkey"];
40+
}
41+
42+
if (options[@"channel"]) {
43+
channel = options[@"channel"];
44+
}
45+
46+
if (options[@"isOpenMessageRoaming"]) {
47+
NSNumber *isOpenMessageRoamingNum = options[@"isOpenMessageRoaming"];
48+
isOpenMessageRoaming = [isOpenMessageRoamingNum boolValue];
49+
}
50+
51+
if (options[@"isProduction"]) {
52+
NSNumber *isProductionNum = options[@"isProduction"];
53+
isProduction = [isProductionNum boolValue];
54+
}
55+
56+
[JMessage addDelegate:self withConversation:nil];
57+
58+
[JMessage setupJMessage:_launchOptions
59+
appKey:appkey
60+
channel:@""
61+
apsForProduction:isProduction
62+
category:nil
63+
messageRoaming:isOpenMessageRoaming];
4064
}
4165

4266
- (void)onReceiveMessageRetractEvent:(JMSGMessageRetractEvent *)retractEvent {

ios/RCTJMessageModule/RCTJMessageModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
#define contactNotifyEvent @"JMessage.ContactNotify" // 收到好友请求消息事件
2727

2828
@interface RCTJMessageModule : NSObject<RCTBridgeModule>
29-
29+
@property(strong, nonatomic)NSDictionary *launchOptions;
3030
@end

ios/RCTJMessageModule/RCTJMessageModule.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ - (id)init {
4949
return self;
5050
}
5151

52+
- (void)setBridge:(RCTBridge *)bridge {
53+
_bridge = bridge;
54+
JMessageHelper.shareInstance.launchOptions = _bridge.launchOptions;
55+
}
56+
5257
-(void)initNotifications {
5358

5459
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];

0 commit comments

Comments
 (0)