cordova-plugin-insider 1.9.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SECURITY.MD +7 -0
- package/package.json +1 -1
- package/plugin.xml +3 -3
- package/src/android/InsiderPlugin.java +46 -1
- package/src/android/build-extras.gradle +3 -4
- package/src/ios/InsiderPlugin.h +4 -0
- package/src/ios/InsiderPlugin.m +53 -5
- package/www/Constants.js +3 -1
- package/www/InsiderPlugin.js +24 -0
package/SECURITY.MD
ADDED
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="cordova-plugin-insider" version="1.
|
|
2
|
+
<plugin id="cordova-plugin-insider" version="2.1.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
3
|
<name>Insider</name>
|
|
4
4
|
<description>Insider Cordova Plugin</description>
|
|
5
5
|
<keywords>insider,cordova,cordova-ios,cordova-android</keywords>
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
<source url="https://cdn.cocoapods.org/" />
|
|
71
71
|
</config>
|
|
72
72
|
<pods use-frameworks="true">
|
|
73
|
-
<pod name="InsiderMobile" spec="13.
|
|
74
|
-
<pod name="InsiderGeofence" spec="1.1.
|
|
73
|
+
<pod name="InsiderMobile" spec="13.4.2" />
|
|
74
|
+
<pod name="InsiderGeofence" spec="1.1.1" />
|
|
75
75
|
<pod name="InsiderHybrid" spec="1.4.0" />
|
|
76
76
|
</pods>
|
|
77
77
|
</podspec>
|
|
@@ -11,7 +11,6 @@ import android.content.pm.PackageManager;
|
|
|
11
11
|
import android.os.Bundle;
|
|
12
12
|
import android.os.Handler;
|
|
13
13
|
import android.os.Looper;
|
|
14
|
-
import android.util.Log;
|
|
15
14
|
|
|
16
15
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
17
16
|
import com.google.firebase.messaging.RemoteMessage;
|
|
@@ -28,6 +27,7 @@ import com.useinsider.insider.RecommendationEngine;
|
|
|
28
27
|
import com.useinsider.insiderhybrid.InsiderHybrid;
|
|
29
28
|
import com.useinsider.insiderhybrid.InsiderHybridUtils;
|
|
30
29
|
import com.useinsider.insiderhybrid.constants.InsiderHybridMethods;
|
|
30
|
+
import com.useinsider.insider.InsiderIDListener;
|
|
31
31
|
|
|
32
32
|
import org.apache.cordova.CallbackContext;
|
|
33
33
|
import org.apache.cordova.CordovaPlugin;
|
|
@@ -49,6 +49,8 @@ import java.util.Map;
|
|
|
49
49
|
public class InsiderPlugin extends CordovaPlugin {
|
|
50
50
|
private boolean isCoreInitialized = false;
|
|
51
51
|
|
|
52
|
+
private InsiderIDListener insiderIDListener;
|
|
53
|
+
|
|
52
54
|
@Override
|
|
53
55
|
protected void pluginInitialize() {
|
|
54
56
|
super.initialize(cordova, webView);
|
|
@@ -99,6 +101,23 @@ public class InsiderPlugin extends CordovaPlugin {
|
|
|
99
101
|
webView.loadUrl("javascript:cordova.fireDocumentEvent('ins_notification_handle'," + json + ");");
|
|
100
102
|
}
|
|
101
103
|
|
|
104
|
+
public void sendInsiderIDToJS(String insiderIDObject) {
|
|
105
|
+
try {
|
|
106
|
+
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
107
|
+
@Override
|
|
108
|
+
public void run() {
|
|
109
|
+
try {
|
|
110
|
+
webView.loadUrl("javascript:cordova.fireDocumentEvent('ins_insider_id_listener'," + insiderIDObject + ");");
|
|
111
|
+
} catch (Exception e) {
|
|
112
|
+
Insider.Instance.putException(e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
} catch (Exception e) {
|
|
117
|
+
Insider.Instance.putException(e);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
@Override
|
|
103
122
|
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
|
|
104
123
|
if (args == null) {
|
|
@@ -639,6 +658,32 @@ public class InsiderPlugin extends CordovaPlugin {
|
|
|
639
658
|
Insider.Instance.signUpConfirmation();
|
|
640
659
|
} else if (action.equals("setPushToken")) {
|
|
641
660
|
Insider.Instance.setPushToken(args.getString(0));
|
|
661
|
+
} else if (action.equals("setEmail")) {
|
|
662
|
+
if (args.get(0) == null)
|
|
663
|
+
return false;
|
|
664
|
+
|
|
665
|
+
Insider.Instance.getCurrentUser().setEmail(args.getString(0));
|
|
666
|
+
} else if (action.equals("setPhoneNumber")) {
|
|
667
|
+
if (args.get(0) == null)
|
|
668
|
+
return false;
|
|
669
|
+
|
|
670
|
+
Insider.Instance.getCurrentUser().setPhoneNumber(args.getString(0));
|
|
671
|
+
} else if (action.equals("getInsiderID")) {
|
|
672
|
+
callbackSuccess(callbackContext, Insider.Instance.getInsiderID());
|
|
673
|
+
} else if (action.equals("registerInsiderIDListener")) {
|
|
674
|
+
if (insiderIDListener == null) {
|
|
675
|
+
insiderIDListener = new InsiderIDListener() {
|
|
676
|
+
@Override
|
|
677
|
+
public void onUpdated(String insiderID) {
|
|
678
|
+
String insiderIDJSONObject = "{ 'insiderID':'" + insiderID + "' }";
|
|
679
|
+
|
|
680
|
+
sendInsiderIDToJS(insiderIDJSONObject);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
Insider.Instance.registerInsiderIDListener(insiderIDListener);
|
|
686
|
+
}
|
|
642
687
|
} else {
|
|
643
688
|
return false;
|
|
644
689
|
}
|
|
@@ -16,7 +16,7 @@ android {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
dependencies {
|
|
19
|
-
implementation 'com.useinsider:insider:14.
|
|
19
|
+
implementation 'com.useinsider:insider:14.2.3'
|
|
20
20
|
implementation 'com.useinsider:insiderhybrid:1.1.6'
|
|
21
21
|
|
|
22
22
|
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
|
|
@@ -24,14 +24,13 @@ dependencies {
|
|
|
24
24
|
|
|
25
25
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
|
26
26
|
implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
|
|
27
|
+
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
|
|
27
28
|
|
|
28
29
|
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
|
29
30
|
implementation 'com.google.firebase:firebase-messaging:23.0.5'
|
|
30
|
-
implementation 'com.google.android.play:
|
|
31
|
+
implementation 'com.google.android.play:review:2.0.1'
|
|
31
32
|
|
|
32
33
|
implementation 'com.huawei.hms:push:6.5.0.300'
|
|
33
34
|
implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
|
|
34
35
|
implementation 'com.huawei.hms:location:6.4.0.300'
|
|
35
|
-
|
|
36
|
-
implementation 'androidx.security:security-crypto:1.0.0'
|
|
37
36
|
}
|
package/src/ios/InsiderPlugin.h
CHANGED
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
- (void) setAge:(CDVInvokedUrlCommand *)command;
|
|
41
41
|
- (void) setSMSOptin:(CDVInvokedUrlCommand *)command;
|
|
42
42
|
- (void) setEmailOptin:(CDVInvokedUrlCommand *)command;
|
|
43
|
+
- (void) setEmail:(CDVInvokedUrlCommand *)command;
|
|
43
44
|
- (void) setPushOptin:(CDVInvokedUrlCommand *)command;
|
|
45
|
+
- (void) setPhoneNumber:(CDVInvokedUrlCommand *)command;
|
|
44
46
|
- (void) setLocationOptin:(CDVInvokedUrlCommand *)command;
|
|
45
47
|
- (void) setWhatsappOptin:(CDVInvokedUrlCommand *)command;
|
|
46
48
|
- (void) setLocale:(CDVInvokedUrlCommand *)command;
|
|
@@ -58,4 +60,6 @@
|
|
|
58
60
|
- (void) signUpConfirmation:(CDVInvokedUrlCommand *)command;
|
|
59
61
|
- (void) putException:(CDVInvokedUrlCommand *)command;
|
|
60
62
|
- (void) handleNotification:(CDVInvokedUrlCommand *)command;
|
|
63
|
+
- (void) getInsiderID:(CDVInvokedUrlCommand *)command;
|
|
64
|
+
- (void) registerInsiderIDListener:(CDVInvokedUrlCommand *)command;
|
|
61
65
|
@end
|
package/src/ios/InsiderPlugin.m
CHANGED
|
@@ -507,6 +507,16 @@
|
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
+
- (void)setPhoneNumber:(CDVInvokedUrlCommand *)command {
|
|
511
|
+
@try {
|
|
512
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
513
|
+
|
|
514
|
+
[Insider getCurrentUser].setPhoneNumber([command.arguments objectAtIndex:0]);
|
|
515
|
+
} @catch (NSException *e) {
|
|
516
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
510
520
|
- (void)setEmailOptin:(CDVInvokedUrlCommand *)command {
|
|
511
521
|
@try {
|
|
512
522
|
if (![command.arguments objectAtIndex:0]) return;
|
|
@@ -516,6 +526,16 @@
|
|
|
516
526
|
}
|
|
517
527
|
}
|
|
518
528
|
|
|
529
|
+
- (void)setEmail:(CDVInvokedUrlCommand *)command {
|
|
530
|
+
@try {
|
|
531
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
532
|
+
|
|
533
|
+
[Insider getCurrentUser].setEmail([command.arguments objectAtIndex:0]);
|
|
534
|
+
} @catch (NSException *e) {
|
|
535
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
519
539
|
- (void)setPushOptin:(CDVInvokedUrlCommand *)command {
|
|
520
540
|
@try {
|
|
521
541
|
if (![command.arguments objectAtIndex:0]) return;
|
|
@@ -674,12 +694,9 @@
|
|
|
674
694
|
[[Insider getCurrentUser] login:insiderIdentifiers insiderIDResult:^(NSString *insiderID) {
|
|
675
695
|
[self sendSuccessResultWithString:insiderID andCommand:command];
|
|
676
696
|
}];
|
|
697
|
+
} else {
|
|
698
|
+
[[Insider getCurrentUser] login:insiderIdentifiers];
|
|
677
699
|
}
|
|
678
|
-
|
|
679
|
-
InsiderUser* currentUser = [Insider getCurrentUser];
|
|
680
|
-
|
|
681
|
-
[currentUser login:insiderIdentifiers];
|
|
682
|
-
|
|
683
700
|
});
|
|
684
701
|
} @catch (NSException *e) {
|
|
685
702
|
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
@@ -752,6 +769,37 @@
|
|
|
752
769
|
}
|
|
753
770
|
}
|
|
754
771
|
|
|
772
|
+
- (void)getInsiderID:(CDVInvokedUrlCommand *)command {
|
|
773
|
+
@try {
|
|
774
|
+
[self sendSuccessResultWithString:[Insider getInsiderID] andCommand:command];
|
|
775
|
+
} @catch (NSException *exception){
|
|
776
|
+
[Insider sendError:exception desc:@"Insider.m - getInsiderID"];
|
|
777
|
+
|
|
778
|
+
[self sendSuccessResultWithString:nil andCommand:command];
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
- (void)registerInsiderIDListener:(CDVInvokedUrlCommand *)command {
|
|
783
|
+
@try {
|
|
784
|
+
[Insider registerInsiderIDListenerWithSelector:@selector(insiderIDChangeListener:) sender:self];
|
|
785
|
+
} @catch (NSException *exception){
|
|
786
|
+
[Insider sendError:exception desc:@"Insider.m - registerInsiderIDListener"];
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
-(void)insiderIDChangeListener:(NSString *)insiderID {
|
|
791
|
+
@try {
|
|
792
|
+
if (insiderID == nil) return;
|
|
793
|
+
|
|
794
|
+
NSString *data = [NSString stringWithFormat:@"{""insiderID"":""'%@'""}", insiderID];
|
|
795
|
+
NSString *js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_insider_id_listener',%@);", data];
|
|
796
|
+
|
|
797
|
+
[self.commandDelegate evalJs:js];
|
|
798
|
+
} @catch (NSException *e){
|
|
799
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
755
803
|
- (void)putException:(CDVInvokedUrlCommand *)command {
|
|
756
804
|
@try {
|
|
757
805
|
if (![command.arguments objectAtIndex:0]) return;
|
package/www/Constants.js
CHANGED
|
@@ -64,6 +64,8 @@ module.exports = {
|
|
|
64
64
|
SET_ACTIVE_FOREGROUND_PUSH_VIEW: 'setActiveForegroundPushView',
|
|
65
65
|
SET_FOREGROUND_PUSH_CALLBACK: 'setForegroundPushCallback',
|
|
66
66
|
HANDLE_NOTIFICATION: 'handleNotification',
|
|
67
|
+
GET_INSIDER_ID: 'getInsiderID',
|
|
68
|
+
REGISTER_INSIDER_ID_LISTENER: 'registerInsiderIDListener',
|
|
67
69
|
// Event
|
|
68
70
|
TAG_EVENT: 'tagEvent',
|
|
69
71
|
// Product Attribute
|
|
@@ -86,5 +88,5 @@ module.exports = {
|
|
|
86
88
|
// Reinit
|
|
87
89
|
REINIT_WITH_PARTNER_NAME: 'reinitWithPartnerName',
|
|
88
90
|
// SDK Version
|
|
89
|
-
SDK_VERSION: 'CDV-1.
|
|
91
|
+
SDK_VERSION: 'CDV-2.1.0',
|
|
90
92
|
};
|
package/www/InsiderPlugin.js
CHANGED
|
@@ -519,6 +519,30 @@ class InsiderPlugin {
|
|
|
519
519
|
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
+
|
|
523
|
+
getInsiderID = () => {
|
|
524
|
+
try {
|
|
525
|
+
return Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.GET_INSIDER_ID, []);
|
|
526
|
+
} catch (error) {
|
|
527
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
528
|
+
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
registerInsiderIDListener = (insiderIDCallback) => {
|
|
534
|
+
try {
|
|
535
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.REGISTER_INSIDER_ID_LISTENER, []);
|
|
536
|
+
|
|
537
|
+
document.addEventListener('ins_insider_id_listener', (event) => {
|
|
538
|
+
if (event.insiderID) {
|
|
539
|
+
insiderIDCallback(event.insiderID);
|
|
540
|
+
}
|
|
541
|
+
}, false);
|
|
542
|
+
} catch (error) {
|
|
543
|
+
Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
522
546
|
}
|
|
523
547
|
|
|
524
548
|
module.exports = new InsiderPlugin();
|