@convep_mobilogy/react-native-qms-plugin 0.10.0 → 0.10.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/android/build.gradle +1 -1
- package/ios/QmsPlugin/QmsDashboardViewManager.mm +41 -1
- package/ios/QmsPlugin/UIViewController+QmsAnalytics.m +81 -0
- package/lib/module/QmsDashboardView.android.js +27 -10
- package/lib/module/QmsDashboardView.android.js.map +1 -1
- package/lib/module/QmsDashboardView.ios.js +21 -5
- package/lib/module/QmsDashboardView.ios.js.map +1 -1
- package/lib/module/QmsPlugin.js +12 -0
- package/lib/module/QmsPlugin.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/QmsDashboardView.android.d.ts.map +1 -1
- package/lib/typescript/src/QmsDashboardView.ios.d.ts.map +1 -1
- package/lib/typescript/src/QmsDashboardView.types.d.ts +3 -0
- package/lib/typescript/src/QmsDashboardView.types.d.ts.map +1 -1
- package/lib/typescript/src/QmsPlugin.d.ts +9 -0
- package/lib/typescript/src/QmsPlugin.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/QmsDashboardView.android.tsx +44 -9
- package/src/QmsDashboardView.ios.tsx +34 -4
- package/src/QmsDashboardView.types.ts +6 -0
- package/src/QmsPlugin.ts +22 -0
- package/src/index.tsx +2 -0
package/android/build.gradle
CHANGED
|
@@ -75,7 +75,7 @@ dependencies {
|
|
|
75
75
|
implementation "com.facebook.react:react-android"
|
|
76
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
77
|
implementation 'com.facebook.react:react-native:+'
|
|
78
|
-
implementation "com.convep.qms:qms-plugin:1.
|
|
78
|
+
implementation "com.convep.qms:qms-plugin:1.12.6"
|
|
79
79
|
|
|
80
80
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
81
81
|
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
@property (nonatomic, copy) NSString *fontFamily;
|
|
17
17
|
|
|
18
18
|
@property (nonatomic, copy) RCTDirectEventBlock onClose;
|
|
19
|
+
@property (nonatomic, copy) RCTDirectEventBlock onAnalyticsScreen;
|
|
20
|
+
@property (nonatomic, copy) RCTDirectEventBlock onAnalyticsEvent;
|
|
19
21
|
@end
|
|
20
22
|
|
|
21
23
|
@implementation QmsDashboardView
|
|
@@ -31,6 +33,14 @@
|
|
|
31
33
|
selector:@selector(handleDashboardClose:)
|
|
32
34
|
name:@"QmsDashboardDidCloseNotification"
|
|
33
35
|
object:nil];
|
|
36
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
37
|
+
selector:@selector(handleAnalyticsScreen:)
|
|
38
|
+
name:@"QmsAnalyticsScreenNotification"
|
|
39
|
+
object:nil];
|
|
40
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
41
|
+
selector:@selector(handleAnalyticsEvent:)
|
|
42
|
+
name:@"QmsAnalyticsEventNotification"
|
|
43
|
+
object:nil];
|
|
34
44
|
}
|
|
35
45
|
return self;
|
|
36
46
|
}
|
|
@@ -67,6 +77,18 @@
|
|
|
67
77
|
[self cleanupDashboard];
|
|
68
78
|
}
|
|
69
79
|
|
|
80
|
+
- (void)handleAnalyticsScreen:(NSNotification *)note {
|
|
81
|
+
if (self.onAnalyticsScreen) {
|
|
82
|
+
self.onAnalyticsScreen(note.userInfo ?: @{});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (void)handleAnalyticsEvent:(NSNotification *)note {
|
|
87
|
+
if (self.onAnalyticsEvent) {
|
|
88
|
+
self.onAnalyticsEvent(note.userInfo ?: @{});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
70
92
|
- (void)cleanupDashboard {
|
|
71
93
|
if (!_dashboardVC) return;
|
|
72
94
|
|
|
@@ -160,6 +182,8 @@ RCT_EXPORT_VIEW_PROPERTY(headerTextColor, NSString)
|
|
|
160
182
|
RCT_EXPORT_VIEW_PROPERTY(headerIconColor, NSString)
|
|
161
183
|
RCT_EXPORT_VIEW_PROPERTY(accentColor, NSString)
|
|
162
184
|
RCT_EXPORT_VIEW_PROPERTY(fontFamily, NSString)
|
|
185
|
+
RCT_EXPORT_VIEW_PROPERTY(onAnalyticsScreen, RCTDirectEventBlock)
|
|
186
|
+
RCT_EXPORT_VIEW_PROPERTY(onAnalyticsEvent, RCTDirectEventBlock)
|
|
163
187
|
|
|
164
188
|
@end
|
|
165
189
|
|
|
@@ -189,12 +213,20 @@ RCT_EXPORT_MODULE();
|
|
|
189
213
|
selector:@selector(handleDashboardClose:)
|
|
190
214
|
name:@"QmsDashboardDidCloseNotification"
|
|
191
215
|
object:nil];
|
|
216
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
217
|
+
selector:@selector(handleAnalyticsScreen:)
|
|
218
|
+
name:@"QmsAnalyticsScreenNotification"
|
|
219
|
+
object:nil];
|
|
220
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
221
|
+
selector:@selector(handleAnalyticsEvent:)
|
|
222
|
+
name:@"QmsAnalyticsEventNotification"
|
|
223
|
+
object:nil];
|
|
192
224
|
}
|
|
193
225
|
return self;
|
|
194
226
|
}
|
|
195
227
|
|
|
196
228
|
- (NSArray<NSString *> *)supportedEvents {
|
|
197
|
-
return @[@"onClose"];
|
|
229
|
+
return @[@"onClose", @"onAnalyticsScreen", @"onAnalyticsEvent"];
|
|
198
230
|
}
|
|
199
231
|
|
|
200
232
|
- (void)handleDashboardClose:(NSNotification *)note {
|
|
@@ -202,6 +234,14 @@ RCT_EXPORT_MODULE();
|
|
|
202
234
|
[self sendEventWithName:@"onClose" body:note.userInfo];
|
|
203
235
|
}
|
|
204
236
|
|
|
237
|
+
- (void)handleAnalyticsScreen:(NSNotification *)note {
|
|
238
|
+
[self sendEventWithName:@"onAnalyticsScreen" body:note.userInfo];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
- (void)handleAnalyticsEvent:(NSNotification *)note {
|
|
242
|
+
[self sendEventWithName:@"onAnalyticsEvent" body:note.userInfo];
|
|
243
|
+
}
|
|
244
|
+
|
|
205
245
|
- (void)dealloc {
|
|
206
246
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
207
247
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
#import <objc/runtime.h>
|
|
4
|
+
|
|
5
|
+
static NSString * const QmsAnalyticsScreenNotification = @"QmsAnalyticsScreenNotification";
|
|
6
|
+
static NSString * const QmsAnalyticsEventNotification = @"QmsAnalyticsEventNotification";
|
|
7
|
+
|
|
8
|
+
@interface UIViewController (QmsAnalytics)
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
@implementation UIViewController (QmsAnalytics)
|
|
12
|
+
|
|
13
|
+
+ (void)load {
|
|
14
|
+
static dispatch_once_t onceToken;
|
|
15
|
+
dispatch_once(&onceToken, ^{
|
|
16
|
+
Class class = [self class];
|
|
17
|
+
SEL originalSelector = @selector(viewDidAppear:);
|
|
18
|
+
SEL swizzledSelector = @selector(qms_viewDidAppear:);
|
|
19
|
+
|
|
20
|
+
Method originalMethod = class_getInstanceMethod(class, originalSelector);
|
|
21
|
+
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
|
|
22
|
+
|
|
23
|
+
BOOL didAddMethod =
|
|
24
|
+
class_addMethod(class,
|
|
25
|
+
originalSelector,
|
|
26
|
+
method_getImplementation(swizzledMethod),
|
|
27
|
+
method_getTypeEncoding(swizzledMethod));
|
|
28
|
+
if (didAddMethod) {
|
|
29
|
+
class_replaceMethod(class,
|
|
30
|
+
swizzledSelector,
|
|
31
|
+
method_getImplementation(originalMethod),
|
|
32
|
+
method_getTypeEncoding(originalMethod));
|
|
33
|
+
} else {
|
|
34
|
+
method_exchangeImplementations(originalMethod, swizzledMethod);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)qms_viewDidAppear:(BOOL)animated {
|
|
40
|
+
[self qms_viewDidAppear:animated];
|
|
41
|
+
|
|
42
|
+
if (![self qms_shouldTrackAnalytics]) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
NSString *screenName = NSStringFromClass([self class]);
|
|
47
|
+
NSString *screenClass = screenName;
|
|
48
|
+
|
|
49
|
+
NSDictionary *screenInfo = @{
|
|
50
|
+
@"screenName": screenName ?: @"",
|
|
51
|
+
@"screenClass": screenClass ?: @""
|
|
52
|
+
};
|
|
53
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:QmsAnalyticsScreenNotification
|
|
54
|
+
object:nil
|
|
55
|
+
userInfo:screenInfo];
|
|
56
|
+
|
|
57
|
+
NSDictionary *eventParams = @{
|
|
58
|
+
@"currentPage": screenName ?: @"",
|
|
59
|
+
@"subCategory": @"Initial"
|
|
60
|
+
};
|
|
61
|
+
NSDictionary *eventInfo = @{
|
|
62
|
+
@"eventName": @"ScreenAt",
|
|
63
|
+
@"params": eventParams
|
|
64
|
+
};
|
|
65
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:QmsAnalyticsEventNotification
|
|
66
|
+
object:nil
|
|
67
|
+
userInfo:eventInfo];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- (BOOL)qms_shouldTrackAnalytics {
|
|
71
|
+
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
|
72
|
+
NSString *bundleId = bundle.bundleIdentifier ?: @"";
|
|
73
|
+
NSString *bundlePath = bundle.bundlePath ?: @"";
|
|
74
|
+
if ([bundleId containsString:@"QmsPluginFramework"] ||
|
|
75
|
+
[bundlePath containsString:@"QmsPluginFramework.framework"]) {
|
|
76
|
+
return YES;
|
|
77
|
+
}
|
|
78
|
+
return NO;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@end
|
|
@@ -10,6 +10,8 @@ export const QmsDashboardView = ({
|
|
|
10
10
|
style,
|
|
11
11
|
onClose,
|
|
12
12
|
onLogout,
|
|
13
|
+
onAnalyticsScreen,
|
|
14
|
+
onAnalyticsEvent,
|
|
13
15
|
clientID,
|
|
14
16
|
clientCode,
|
|
15
17
|
ClientID,
|
|
@@ -19,6 +21,7 @@ export const QmsDashboardView = ({
|
|
|
19
21
|
userToken,
|
|
20
22
|
autoShow = true,
|
|
21
23
|
themeColor,
|
|
24
|
+
headerThemeColor,
|
|
22
25
|
headerTextColor,
|
|
23
26
|
headerIconColor,
|
|
24
27
|
accentColor,
|
|
@@ -35,11 +38,13 @@ export const QmsDashboardView = ({
|
|
|
35
38
|
if (themeColor && QmsModule?.setPrimaryColor) {
|
|
36
39
|
QmsModule.setPrimaryColor(themeColor);
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const resolvedHeaderColor = headerThemeColor ?? headerTextColor;
|
|
42
|
+
if (resolvedHeaderColor && QmsModule?.setHeaderTextColor) {
|
|
43
|
+
QmsModule.setHeaderTextColor(resolvedHeaderColor);
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
const resolvedHeaderIconColor = headerThemeColor ?? headerIconColor;
|
|
46
|
+
if (resolvedHeaderIconColor && QmsModule?.setHeaderIconColor) {
|
|
47
|
+
QmsModule.setHeaderIconColor(resolvedHeaderIconColor);
|
|
43
48
|
}
|
|
44
49
|
if (accentColor && QmsModule?.setAccentColor) {
|
|
45
50
|
QmsModule.setAccentColor(accentColor);
|
|
@@ -54,16 +59,18 @@ export const QmsDashboardView = ({
|
|
|
54
59
|
QmsModule.showQms(resolvedToken, resolvedClientID, resolvedClientCode, isOrigin);
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
|
-
}, [clientID, clientCode, ClientID, ClientCode, user_token, token, userToken, autoShow, themeColor, headerTextColor, headerIconColor, accentColor, fontFamily, isOrigin, payload]);
|
|
62
|
+
}, [clientID, clientCode, ClientID, ClientCode, user_token, token, userToken, autoShow, themeColor, headerThemeColor, headerTextColor, headerIconColor, accentColor, fontFamily, isOrigin, payload]);
|
|
58
63
|
useEffect(() => {
|
|
59
64
|
if (themeColor && QmsModule?.setPrimaryColor) {
|
|
60
65
|
QmsModule.setPrimaryColor(themeColor);
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
const resolvedHeaderColor = headerThemeColor ?? headerTextColor;
|
|
68
|
+
if (resolvedHeaderColor && QmsModule?.setHeaderTextColor) {
|
|
69
|
+
QmsModule.setHeaderTextColor(resolvedHeaderColor);
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const resolvedHeaderIconColor = headerThemeColor ?? headerIconColor;
|
|
72
|
+
if (resolvedHeaderIconColor && QmsModule?.setHeaderIconColor) {
|
|
73
|
+
QmsModule.setHeaderIconColor(resolvedHeaderIconColor);
|
|
67
74
|
}
|
|
68
75
|
if (accentColor && QmsModule?.setAccentColor) {
|
|
69
76
|
QmsModule.setAccentColor(accentColor);
|
|
@@ -71,7 +78,7 @@ export const QmsDashboardView = ({
|
|
|
71
78
|
if (QmsModule?.setFontFamily) {
|
|
72
79
|
QmsModule.setFontFamily(fontFamily ?? '');
|
|
73
80
|
}
|
|
74
|
-
}, [themeColor, headerTextColor, headerIconColor, accentColor, fontFamily]);
|
|
81
|
+
}, [themeColor, headerThemeColor, headerTextColor, headerIconColor, accentColor, fontFamily]);
|
|
75
82
|
useEffect(() => {
|
|
76
83
|
if (!onClose) return;
|
|
77
84
|
const subscription = DeviceEventEmitter.addListener('QmsSdkOnClose', () => onClose());
|
|
@@ -82,6 +89,16 @@ export const QmsDashboardView = ({
|
|
|
82
89
|
const subscription = DeviceEventEmitter.addListener('QmsSdkOnLogout', () => onLogout());
|
|
83
90
|
return () => subscription.remove();
|
|
84
91
|
}, [onLogout]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!onAnalyticsScreen) return;
|
|
94
|
+
const subscription = DeviceEventEmitter.addListener('QmsSdkOnAnalyticsScreen', event => onAnalyticsScreen(event?.screenName, event?.screenClass));
|
|
95
|
+
return () => subscription.remove();
|
|
96
|
+
}, [onAnalyticsScreen]);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (!onAnalyticsEvent) return;
|
|
99
|
+
const subscription = DeviceEventEmitter.addListener('QmsSdkOnAnalyticsEvent', event => onAnalyticsEvent(event?.eventName, event?.params ?? null));
|
|
100
|
+
return () => subscription.remove();
|
|
101
|
+
}, [onAnalyticsEvent]);
|
|
85
102
|
|
|
86
103
|
// Android doesn’t need to show native UI as a "view" here,
|
|
87
104
|
// we just render an empty container so JSX stays consistent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","DeviceEventEmitter","NativeModules","View","jsx","_jsx","QmsModule","QmsDashboardView","style","onClose","onLogout","clientID","clientCode","ClientID","ClientCode","user_token","token","userToken","autoShow","themeColor","headerTextColor","headerIconColor","accentColor","fontFamily","isOrigin","payload","resolvedClientID","resolvedClientCode","resolvedToken","hasPayload","Object","keys","length","showQms","setPrimaryColor","setHeaderTextColor","setHeaderIconColor","setAccentColor","setFontFamily","showQmsWithPayload","subscription","addListener","remove"],"sourceRoot":"../../src","sources":["QmsDashboardView.android.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,kBAAkB,EAAEC,aAAa,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGvE,MAAM;EAAEC;AAAU,CAAC,GAAGJ,aAqBrB;AAED,OAAO,MAAMK,gBAAiD,GAAGA,CAAC;EAChEC,KAAK;EACLC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,UAAU;EACVC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC,SAAS;EACTC,QAAQ,GAAG,IAAI;EACfC,UAAU;EACVC,eAAe;EACfC,eAAe;EACfC,WAAW;EACXC,UAAU;EACVC,QAAQ,GAAG,KAAK;EAChBC;AACF,CAAC,KAAK;
|
|
1
|
+
{"version":3,"names":["React","useEffect","DeviceEventEmitter","NativeModules","View","jsx","_jsx","QmsModule","QmsDashboardView","style","onClose","onLogout","onAnalyticsScreen","onAnalyticsEvent","clientID","clientCode","ClientID","ClientCode","user_token","token","userToken","autoShow","themeColor","headerThemeColor","headerTextColor","headerIconColor","accentColor","fontFamily","isOrigin","payload","resolvedClientID","resolvedClientCode","resolvedToken","hasPayload","Object","keys","length","showQms","setPrimaryColor","resolvedHeaderColor","setHeaderTextColor","resolvedHeaderIconColor","setHeaderIconColor","setAccentColor","setFontFamily","showQmsWithPayload","subscription","addListener","remove","event","screenName","screenClass","eventName","params"],"sourceRoot":"../../src","sources":["QmsDashboardView.android.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,kBAAkB,EAAEC,aAAa,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGvE,MAAM;EAAEC;AAAU,CAAC,GAAGJ,aAqBrB;AAED,OAAO,MAAMK,gBAAiD,GAAGA,CAAC;EAChEC,KAAK;EACLC,OAAO;EACPC,QAAQ;EACRC,iBAAiB;EACjBC,gBAAgB;EAChBC,QAAQ;EACRC,UAAU;EACVC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC,SAAS;EACTC,QAAQ,GAAG,IAAI;EACfC,UAAU;EACVC,gBAAgB;EAChBC,eAAe;EACfC,eAAe;EACfC,WAAW;EACXC,UAAU;EACVC,QAAQ,GAAG,KAAK;EAChBC;AACF,CAAC,KAAK;EACJ5B,SAAS,CAAC,MAAM;IACd,MAAM6B,gBAAgB,GAAGhB,QAAQ,IAAIE,QAAQ,IAAI,EAAE;IACnD,MAAMe,kBAAkB,GAAGhB,UAAU,IAAIE,UAAU,IAAI,EAAE;IACzD,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AI,CAACU,QAAQ,EAAE;IACf,MAAMmC,YAAY,GAAG5C,kBAAkB,CAAC6C,WAAW,CAAC,gBAAgB,EAAE,MACpEpC,QAAQ,CAAC,CACX,CAAC;IACD,OAAO,MAAMmC,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,CAACrC,QAAQ,CAAC,CAAC;EAEdV,SAAS,CAAC,MAAM;IACd,IAAI,CAACW,iBAAiB,EAAE;IACxB,MAAMkC,YAAY,GAAG5C,kBAAkB,CAAC6C,WAAW,CACjD,yBAAyB,EACxBE,KAAqD,IACpDrC,iBAAiB,CAACqC,KAAK,EAAEC,UAAU,EAAED,KAAK,EAAEE,WAAW,CAC3D,CAAC;IACD,OAAO,MAAML,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,CAACpC,iBAAiB,CAAC,CAAC;EAEvBX,SAAS,CAAC,MAAM;IACd,IAAI,CAACY,gBAAgB,EAAE;IACvB,MAAMiC,YAAY,GAAG5C,kBAAkB,CAAC6C,WAAW,CACjD,wBAAwB,EACvBE,KAAgE,IAC/DpC,gBAAgB,CAACoC,KAAK,EAAEG,SAAS,EAAEH,KAAK,EAAEI,MAAM,IAAI,IAAI,CAC5D,CAAC;IACD,OAAO,MAAMP,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,CAACnC,gBAAgB,CAAC,CAAC;;EAEtB;EACA;EACA,oBAAOP,IAAA,CAACF,IAAI;IAACK,KAAK,EAAEA;EAAM,CAAE,CAAC;AAC/B,CAAC","ignoreList":[]}
|
|
@@ -8,6 +8,8 @@ const NativeQmsDashboardView = requireNativeComponent('QmsDashboardView');
|
|
|
8
8
|
export const QmsDashboardView = props => {
|
|
9
9
|
const {
|
|
10
10
|
onClose,
|
|
11
|
+
onAnalyticsScreen,
|
|
12
|
+
onAnalyticsEvent,
|
|
11
13
|
// onLogout,
|
|
12
14
|
clientID,
|
|
13
15
|
clientCode,
|
|
@@ -18,24 +20,38 @@ export const QmsDashboardView = props => {
|
|
|
18
20
|
token,
|
|
19
21
|
// isOrigin,
|
|
20
22
|
// autoShow is Android-only; ignored on iOS
|
|
23
|
+
headerThemeColor,
|
|
24
|
+
headerTextColor,
|
|
25
|
+
headerIconColor,
|
|
21
26
|
...rest
|
|
22
27
|
} = props;
|
|
23
28
|
const resolvedClientID = clientID ?? ClientID ?? '';
|
|
24
29
|
const resolvedClientCode = clientCode ?? ClientCode ?? '';
|
|
25
30
|
const resolvedToken = user_token ?? token ?? userToken ?? '';
|
|
26
31
|
useEffect(() => {
|
|
27
|
-
if (!onClose) return;
|
|
32
|
+
if (!onClose && !onAnalyticsScreen && !onAnalyticsEvent) return;
|
|
28
33
|
const nativeEmitterModule = NativeModules.QmsDashboardEmitter;
|
|
29
34
|
if (!nativeEmitterModule) return;
|
|
30
35
|
const emitter = new NativeEventEmitter(nativeEmitterModule);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const subscriptions = [];
|
|
37
|
+
if (onClose) {
|
|
38
|
+
subscriptions.push(emitter.addListener('onClose', onClose));
|
|
39
|
+
}
|
|
40
|
+
if (onAnalyticsScreen) {
|
|
41
|
+
subscriptions.push(emitter.addListener('onAnalyticsScreen', payload => onAnalyticsScreen(payload?.screenName, payload?.screenClass)));
|
|
42
|
+
}
|
|
43
|
+
if (onAnalyticsEvent) {
|
|
44
|
+
subscriptions.push(emitter.addListener('onAnalyticsEvent', payload => onAnalyticsEvent(payload?.eventName, payload?.params ?? null)));
|
|
45
|
+
}
|
|
46
|
+
return () => subscriptions.forEach(sub => sub.remove());
|
|
47
|
+
}, [onClose, onAnalyticsScreen, onAnalyticsEvent]);
|
|
34
48
|
return /*#__PURE__*/_jsx(NativeQmsDashboardView, {
|
|
35
49
|
...rest,
|
|
36
50
|
ClientID: resolvedClientID,
|
|
37
51
|
ClientCode: resolvedClientCode,
|
|
38
|
-
user_token: resolvedToken
|
|
52
|
+
user_token: resolvedToken,
|
|
53
|
+
headerTextColor: headerThemeColor ?? headerTextColor,
|
|
54
|
+
headerIconColor: headerThemeColor ?? headerIconColor
|
|
39
55
|
});
|
|
40
56
|
};
|
|
41
57
|
//# sourceMappingURL=QmsDashboardView.ios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","NativeEventEmitter","NativeModules","requireNativeComponent","jsx","_jsx","NativeQmsDashboardView","QmsDashboardView","props","onClose","clientID","clientCode","ClientID","ClientCode","user_token","userToken","token","rest","resolvedClientID","resolvedClientCode","resolvedToken","nativeEmitterModule","QmsDashboardEmitter","emitter","
|
|
1
|
+
{"version":3,"names":["React","useEffect","NativeEventEmitter","NativeModules","requireNativeComponent","jsx","_jsx","NativeQmsDashboardView","QmsDashboardView","props","onClose","onAnalyticsScreen","onAnalyticsEvent","clientID","clientCode","ClientID","ClientCode","user_token","userToken","token","headerThemeColor","headerTextColor","headerIconColor","rest","resolvedClientID","resolvedClientCode","resolvedToken","nativeEmitterModule","QmsDashboardEmitter","emitter","subscriptions","push","addListener","payload","screenName","screenClass","eventName","params","forEach","sub","remove"],"sourceRoot":"../../src","sources":["QmsDashboardView.ios.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SACEC,kBAAkB,EAClBC,aAAa,EACbC,sBAAsB,QACjB,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGtB;AACA,MAAMC,sBAAsB,GAC1BH,sBAAsB,CAAwB,kBAAkB,CAAC;AAEnE,OAAO,MAAMI,gBAAiD,GAAIC,KAAK,IAAK;EAC1E,MAAM;IACJC,OAAO;IACPC,iBAAiB;IACjBC,gBAAgB;IAChB;IACAC,QAAQ;IACRC,UAAU;IACVC,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,SAAS;IACTC,KAAK;IACL;IACA;IACAC,gBAAgB;IAChBC,eAAe;IACfC,eAAe;IACf,GAAGC;EACL,CAAC,GAAGd,KAAK;EAET,MAAMe,gBAAgB,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B;IAC3BR,UAAU,EAAES,kBAAmB;IAC/BR,UAAU,EAAES,aAAc;IAC1BL,eAAe,EAAED,gBAAgB,IAAIC,eAAgB;IACrDC,eAAe,EAAEF,gBAAgB,IAAIE;EAAgB,CACtD,CAAC;AAEN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules } from 'react-native';
|
|
4
|
+
const {
|
|
5
|
+
QmsModule
|
|
6
|
+
} = NativeModules;
|
|
7
|
+
export const QmsPlugin = {
|
|
8
|
+
emitInAppNotification(payload) {
|
|
9
|
+
QmsModule?.emitInAppNotification?.(payload.title ?? 'Notification', payload.body ?? '');
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=QmsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","QmsModule","QmsPlugin","emitInAppNotification","payload","title","body"],"sourceRoot":"../../src","sources":["QmsPlugin.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAQ5C,MAAM;EAAEC;AAAU,CAAC,GAAGD,aAIrB;AAED,OAAO,MAAME,SAAS,GAAG;EACvBC,qBAAqBA,CAACC,OAAiC,EAAQ;IAC7DH,SAAS,EAAEE,qBAAqB,GAC9BC,OAAO,CAACC,KAAK,IAAI,cAAc,EAC/BD,OAAO,CAACE,IAAI,IAAI,EAClB,CAAC;EACH;AACF,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["QmsDashboardView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,uBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["QmsDashboardView","QmsPlugin"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,uBAAoB;AAErD,SAASC,SAAS,QAAQ,gBAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QmsDashboardView.android.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAyBtE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"QmsDashboardView.android.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAyBtE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAsJ5D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QmsDashboardView.ios.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAMtE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"QmsDashboardView.ios.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAMtE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAmE5D,CAAC"}
|
|
@@ -3,6 +3,8 @@ export type QmsDashboardViewProps = {
|
|
|
3
3
|
style?: StyleProp<ViewStyle>;
|
|
4
4
|
onClose?: (event?: unknown) => void;
|
|
5
5
|
onLogout?: (event?: unknown) => void;
|
|
6
|
+
onAnalyticsScreen?: (screenName?: string, screenClass?: string) => void;
|
|
7
|
+
onAnalyticsEvent?: (eventName?: string, params?: Record<string, unknown> | null) => void;
|
|
6
8
|
/**
|
|
7
9
|
* Preferred camelCase props. Uppercase variants are kept for backwards compatibility
|
|
8
10
|
* with the native iOS view manager prop names.
|
|
@@ -16,6 +18,7 @@ export type QmsDashboardViewProps = {
|
|
|
16
18
|
token?: string;
|
|
17
19
|
autoShow?: boolean;
|
|
18
20
|
themeColor?: string;
|
|
21
|
+
headerThemeColor?: string;
|
|
19
22
|
headerTextColor?: string;
|
|
20
23
|
headerIconColor?: string;
|
|
21
24
|
accentColor?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QmsDashboardView.types.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,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;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QmsPlugin.d.ts","sourceRoot":"","sources":["../../../src/QmsPlugin.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAQF,eAAO,MAAM,SAAS;mCACW,wBAAwB,GAAG,IAAI;CAM/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -29,6 +29,8 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
29
29
|
style,
|
|
30
30
|
onClose,
|
|
31
31
|
onLogout,
|
|
32
|
+
onAnalyticsScreen,
|
|
33
|
+
onAnalyticsEvent,
|
|
32
34
|
clientID,
|
|
33
35
|
clientCode,
|
|
34
36
|
ClientID,
|
|
@@ -38,6 +40,7 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
38
40
|
userToken,
|
|
39
41
|
autoShow = true,
|
|
40
42
|
themeColor,
|
|
43
|
+
headerThemeColor,
|
|
41
44
|
headerTextColor,
|
|
42
45
|
headerIconColor,
|
|
43
46
|
accentColor,
|
|
@@ -55,11 +58,13 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
55
58
|
if (themeColor && QmsModule?.setPrimaryColor) {
|
|
56
59
|
QmsModule.setPrimaryColor(themeColor);
|
|
57
60
|
}
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
const resolvedHeaderColor = headerThemeColor ?? headerTextColor;
|
|
62
|
+
if (resolvedHeaderColor && QmsModule?.setHeaderTextColor) {
|
|
63
|
+
QmsModule.setHeaderTextColor(resolvedHeaderColor);
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
const resolvedHeaderIconColor = headerThemeColor ?? headerIconColor;
|
|
66
|
+
if (resolvedHeaderIconColor && QmsModule?.setHeaderIconColor) {
|
|
67
|
+
QmsModule.setHeaderIconColor(resolvedHeaderIconColor);
|
|
63
68
|
}
|
|
64
69
|
if (accentColor && QmsModule?.setAccentColor) {
|
|
65
70
|
QmsModule.setAccentColor(accentColor);
|
|
@@ -95,6 +100,7 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
95
100
|
userToken,
|
|
96
101
|
autoShow,
|
|
97
102
|
themeColor,
|
|
103
|
+
headerThemeColor,
|
|
98
104
|
headerTextColor,
|
|
99
105
|
headerIconColor,
|
|
100
106
|
accentColor,
|
|
@@ -107,11 +113,13 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
107
113
|
if (themeColor && QmsModule?.setPrimaryColor) {
|
|
108
114
|
QmsModule.setPrimaryColor(themeColor);
|
|
109
115
|
}
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
const resolvedHeaderColor = headerThemeColor ?? headerTextColor;
|
|
117
|
+
if (resolvedHeaderColor && QmsModule?.setHeaderTextColor) {
|
|
118
|
+
QmsModule.setHeaderTextColor(resolvedHeaderColor);
|
|
112
119
|
}
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
const resolvedHeaderIconColor = headerThemeColor ?? headerIconColor;
|
|
121
|
+
if (resolvedHeaderIconColor && QmsModule?.setHeaderIconColor) {
|
|
122
|
+
QmsModule.setHeaderIconColor(resolvedHeaderIconColor);
|
|
115
123
|
}
|
|
116
124
|
if (accentColor && QmsModule?.setAccentColor) {
|
|
117
125
|
QmsModule.setAccentColor(accentColor);
|
|
@@ -119,7 +127,14 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
119
127
|
if (QmsModule?.setFontFamily) {
|
|
120
128
|
QmsModule.setFontFamily(fontFamily ?? '');
|
|
121
129
|
}
|
|
122
|
-
}, [
|
|
130
|
+
}, [
|
|
131
|
+
themeColor,
|
|
132
|
+
headerThemeColor,
|
|
133
|
+
headerTextColor,
|
|
134
|
+
headerIconColor,
|
|
135
|
+
accentColor,
|
|
136
|
+
fontFamily,
|
|
137
|
+
]);
|
|
123
138
|
|
|
124
139
|
useEffect(() => {
|
|
125
140
|
if (!onClose) return;
|
|
@@ -137,6 +152,26 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = ({
|
|
|
137
152
|
return () => subscription.remove();
|
|
138
153
|
}, [onLogout]);
|
|
139
154
|
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (!onAnalyticsScreen) return;
|
|
157
|
+
const subscription = DeviceEventEmitter.addListener(
|
|
158
|
+
'QmsSdkOnAnalyticsScreen',
|
|
159
|
+
(event?: { screenName?: string; screenClass?: string }) =>
|
|
160
|
+
onAnalyticsScreen(event?.screenName, event?.screenClass)
|
|
161
|
+
);
|
|
162
|
+
return () => subscription.remove();
|
|
163
|
+
}, [onAnalyticsScreen]);
|
|
164
|
+
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (!onAnalyticsEvent) return;
|
|
167
|
+
const subscription = DeviceEventEmitter.addListener(
|
|
168
|
+
'QmsSdkOnAnalyticsEvent',
|
|
169
|
+
(event?: { eventName?: string; params?: Record<string, unknown> }) =>
|
|
170
|
+
onAnalyticsEvent(event?.eventName, event?.params ?? null)
|
|
171
|
+
);
|
|
172
|
+
return () => subscription.remove();
|
|
173
|
+
}, [onAnalyticsEvent]);
|
|
174
|
+
|
|
140
175
|
// Android doesn’t need to show native UI as a "view" here,
|
|
141
176
|
// we just render an empty container so JSX stays consistent.
|
|
142
177
|
return <View style={style} />;
|
|
@@ -13,6 +13,8 @@ const NativeQmsDashboardView =
|
|
|
13
13
|
export const QmsDashboardView: React.FC<QmsDashboardViewProps> = (props) => {
|
|
14
14
|
const {
|
|
15
15
|
onClose,
|
|
16
|
+
onAnalyticsScreen,
|
|
17
|
+
onAnalyticsEvent,
|
|
16
18
|
// onLogout,
|
|
17
19
|
clientID,
|
|
18
20
|
clientCode,
|
|
@@ -23,6 +25,9 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = (props) => {
|
|
|
23
25
|
token,
|
|
24
26
|
// isOrigin,
|
|
25
27
|
// autoShow is Android-only; ignored on iOS
|
|
28
|
+
headerThemeColor,
|
|
29
|
+
headerTextColor,
|
|
30
|
+
headerIconColor,
|
|
26
31
|
...rest
|
|
27
32
|
} = props;
|
|
28
33
|
|
|
@@ -31,13 +36,36 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = (props) => {
|
|
|
31
36
|
const resolvedToken = user_token ?? token ?? userToken ?? '';
|
|
32
37
|
|
|
33
38
|
useEffect(() => {
|
|
34
|
-
if (!onClose) return;
|
|
39
|
+
if (!onClose && !onAnalyticsScreen && !onAnalyticsEvent) return;
|
|
35
40
|
const nativeEmitterModule = NativeModules.QmsDashboardEmitter;
|
|
36
41
|
if (!nativeEmitterModule) return;
|
|
37
42
|
const emitter = new NativeEventEmitter(nativeEmitterModule);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
const subscriptions: { remove: () => void }[] = [];
|
|
44
|
+
if (onClose) {
|
|
45
|
+
subscriptions.push(emitter.addListener('onClose', onClose));
|
|
46
|
+
}
|
|
47
|
+
if (onAnalyticsScreen) {
|
|
48
|
+
subscriptions.push(
|
|
49
|
+
emitter.addListener(
|
|
50
|
+
'onAnalyticsScreen',
|
|
51
|
+
(payload?: { screenName?: string; screenClass?: string }) =>
|
|
52
|
+
onAnalyticsScreen(payload?.screenName, payload?.screenClass)
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (onAnalyticsEvent) {
|
|
57
|
+
subscriptions.push(
|
|
58
|
+
emitter.addListener(
|
|
59
|
+
'onAnalyticsEvent',
|
|
60
|
+
(payload?: {
|
|
61
|
+
eventName?: string;
|
|
62
|
+
params?: Record<string, unknown>;
|
|
63
|
+
}) => onAnalyticsEvent(payload?.eventName, payload?.params ?? null)
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return () => subscriptions.forEach((sub) => sub.remove());
|
|
68
|
+
}, [onClose, onAnalyticsScreen, onAnalyticsEvent]);
|
|
41
69
|
|
|
42
70
|
return (
|
|
43
71
|
<NativeQmsDashboardView
|
|
@@ -45,6 +73,8 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = (props) => {
|
|
|
45
73
|
ClientID={resolvedClientID}
|
|
46
74
|
ClientCode={resolvedClientCode}
|
|
47
75
|
user_token={resolvedToken}
|
|
76
|
+
headerTextColor={headerThemeColor ?? headerTextColor}
|
|
77
|
+
headerIconColor={headerThemeColor ?? headerIconColor}
|
|
48
78
|
/>
|
|
49
79
|
);
|
|
50
80
|
};
|
|
@@ -4,6 +4,11 @@ export type QmsDashboardViewProps = {
|
|
|
4
4
|
style?: StyleProp<ViewStyle>;
|
|
5
5
|
onClose?: (event?: unknown) => void;
|
|
6
6
|
onLogout?: (event?: unknown) => void;
|
|
7
|
+
onAnalyticsScreen?: (screenName?: string, screenClass?: string) => void;
|
|
8
|
+
onAnalyticsEvent?: (
|
|
9
|
+
eventName?: string,
|
|
10
|
+
params?: Record<string, unknown> | null
|
|
11
|
+
) => void;
|
|
7
12
|
/**
|
|
8
13
|
* Preferred camelCase props. Uppercase variants are kept for backwards compatibility
|
|
9
14
|
* with the native iOS view manager prop names.
|
|
@@ -17,6 +22,7 @@ export type QmsDashboardViewProps = {
|
|
|
17
22
|
token?: string;
|
|
18
23
|
autoShow?: boolean; // optional: Android uses this, iOS can ignore
|
|
19
24
|
themeColor?: string;
|
|
25
|
+
headerThemeColor?: string;
|
|
20
26
|
headerTextColor?: string;
|
|
21
27
|
headerIconColor?: string;
|
|
22
28
|
accentColor?: string;
|
package/src/QmsPlugin.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type InAppNotificationPayload = {
|
|
4
|
+
title?: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const { QmsModule } = NativeModules as {
|
|
10
|
+
QmsModule?: {
|
|
11
|
+
emitInAppNotification?: (title?: string, body?: string) => void;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const QmsPlugin = {
|
|
16
|
+
emitInAppNotification(payload: InAppNotificationPayload): void {
|
|
17
|
+
QmsModule?.emitInAppNotification?.(
|
|
18
|
+
payload.title ?? 'Notification',
|
|
19
|
+
payload.body ?? ''
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
};
|
package/src/index.tsx
CHANGED