cordova-plugin-repro 6.7.0 → 6.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-repro",
3
- "version": "6.7.0",
3
+ "version": "6.10.0",
4
4
  "description": "Repro Cordova Plugin",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-repro",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0' encoding='UTF-8'?>
2
2
 
3
- <plugin xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-repro" version="6.7.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
3
+ <plugin xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-repro" version="6.10.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
4
4
  <name>Repro</name>
5
5
  <description>Repro Cordova Plugin</description>
6
6
  <license>Commercial</license>
@@ -74,3 +74,6 @@
74
74
 
75
75
 
76
76
 
77
+
78
+
79
+
@@ -1,5 +1,5 @@
1
1
  {
2
- "ios-sdk": "5.8.0",
3
- "android-sdk": "5.6.0",
4
- "bridge": "6.7.0"
2
+ "ios-sdk": "5.9.0",
3
+ "android-sdk": "5.7.0",
4
+ "bridge": "6.10.0"
5
5
  }
@@ -1,11 +1,15 @@
1
1
  package io.repro.cordova;
2
2
 
3
+ import android.app.AppOpsManager;
3
4
  import android.content.Context;
4
5
  import android.graphics.Point;
5
6
  import android.graphics.Rect;
6
7
  import android.view.Display;
7
8
  import android.view.WindowManager;
9
+ import android.net.Uri;
8
10
 
11
+ import java.lang.reflect.Field;
12
+ import java.lang.reflect.Method;
9
13
  import java.text.SimpleDateFormat;
10
14
  import java.util.EnumSet;
11
15
  import java.util.Date;
@@ -20,6 +24,9 @@ import java.util.TimeZone;
20
24
  import org.apache.cordova.CallbackContext;
21
25
  import org.apache.cordova.CordovaArgs;
22
26
 
27
+ import org.apache.cordova.CordovaWebView;
28
+ import org.apache.cordova.LOG;
29
+ import org.apache.cordova.PluginResult;
23
30
  import org.json.JSONArray;
24
31
  import org.json.JSONException;
25
32
  import org.json.JSONObject;
@@ -35,6 +42,8 @@ import io.repro.android.newsfeed.NewsFeedCampaignType;
35
42
  */
36
43
  public final class CordovaPlugin extends org.apache.cordova.CordovaPlugin {
37
44
 
45
+ private static final String REPRO_CORDOVA_BRIDGE_VERSION = "6.10.0";
46
+
38
47
  private static SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
39
48
 
40
49
  static {
@@ -148,10 +157,35 @@ public final class CordovaPlugin extends org.apache.cordova.CordovaPlugin {
148
157
  else if ("updateNewsFeeds".equals(action)) {
149
158
  return updateNewsFeeds(args, callbackContext);
150
159
  }
160
+ else if ("setOpenUrlCallback".equals(action)) {
161
+ return setOpenUrlCallback(args, callbackContext);
162
+ }
151
163
 
152
164
  return false;
153
165
  }
154
166
 
167
+ private void passPlatformValues() {
168
+ final Map<String, Object> platformValues = new HashMap<>();
169
+ platformValues.put("sub_sdk_platform", "cordova");
170
+ platformValues.put("sub_sdk_bridge_version", REPRO_CORDOVA_BRIDGE_VERSION);
171
+
172
+ try {
173
+ Class cordovaKlass = Class.forName("org.apache.cordova.CordovaWebView");
174
+ Field verField = cordovaKlass.getDeclaredField("CORDOVA_VERSION");
175
+ platformValues.put("sub_sdk_platform_version", (String)verField.get(null)); // null because static field
176
+ } catch (Throwable t) {
177
+ t.printStackTrace();
178
+ }
179
+
180
+ try {
181
+ Method method = Repro.class.getDeclaredMethod("_passRuntimeValues", Map.class);
182
+ method.setAccessible(true);
183
+ method.invoke(null, platformValues);
184
+ } catch (Throwable t) {
185
+ t.printStackTrace();
186
+ }
187
+ }
188
+
155
189
  // API implementation
156
190
  // CordovaArgs: https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaArgs.java
157
191
 
@@ -160,6 +194,7 @@ public final class CordovaPlugin extends org.apache.cordova.CordovaPlugin {
160
194
 
161
195
  callAPI(new API(callbackContext) {
162
196
  Void api() {
197
+ passPlatformValues();
163
198
  CordovaBridge.startSession(token);
164
199
  return null;
165
200
  }
@@ -824,6 +859,18 @@ public final class CordovaPlugin extends org.apache.cordova.CordovaPlugin {
824
859
  return true;
825
860
  }
826
861
 
862
+ private boolean setOpenUrlCallback(final CordovaArgs args, final CallbackContext callbackContext) {
863
+ Repro.setOpenUrlCallback(new Repro.OpenUrlCallback() {
864
+ @Override
865
+ public void onOpened(Uri uri) {
866
+ PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, uri.toString());
867
+ pluginResult.setKeepCallback(true);
868
+ callbackContext.sendPluginResult(pluginResult);
869
+ }
870
+ });
871
+ return true;
872
+ }
873
+
827
874
  // helper
828
875
 
829
876
  private static abstract class API<T> implements Runnable {
Binary file
@@ -1,6 +1,6 @@
1
1
  repositories {
2
2
  google()
3
- jcenter()
3
+ mavenCentral()
4
4
  flatDir {
5
5
  dirs 'src/main/libs'
6
6
  dirs 'libs'
@@ -20,24 +20,11 @@ dependencies {
20
20
 
21
21
  buildscript {
22
22
  repositories {
23
- jcenter()
23
+ mavenCentral()
24
24
  google()
25
25
  }
26
26
 
27
27
  dependencies {
28
28
  classpath 'com.android.tools.build:gradle:+'
29
- classpath 'com.google.gms:google-services:4.0.2'
30
29
  }
31
30
  }
32
-
33
- cdvPluginPostBuildExtras.add({
34
- def skipGoogleServicesPluginApply = false
35
- project.rootDir.eachDir { dir ->
36
- if (dir.getName() == "cordova-support-google-services" || dir.getName() == "phonegap-plugin-push") {
37
- skipGoogleServicesPluginApply = true
38
- }
39
- }
40
- if(!skipGoogleServicesPluginApply && project.plugins.findPlugin("com.google.gms.google-services") == null) {
41
- apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
42
- }
43
- })
@@ -7,6 +7,8 @@
7
7
 
8
8
  #import <Cordova/CDV.h>
9
9
 
10
+ #define REPRO_CORDOVA_BRIDGE_VERSION "6.10.0"
11
+
10
12
  @interface CDVRepro : CDVPlugin
11
13
 
12
14
  @end
@@ -13,12 +13,38 @@
13
13
  #import "CDVRepro.h"
14
14
  #import "CDVReproEventPropertiesFactory.h"
15
15
 
16
+
17
+ #if __has_include(<Cordova/CDVAvailability.h>)
18
+ #import <Cordova/CDVAvailability.h>
19
+ #elif __has_include("CDVAvailability.h")
20
+ #import "CDVAvailability.h"
21
+ #elif __has_include("Cordova/CDVAvailability.h")
22
+ #import "Cordova/CDVAvailability.h"
23
+ #endif
24
+
25
+
16
26
  #define isNSNumber(OBJECT) ([OBJECT isKindOfClass:NSNumber.class])
17
27
 
28
+
29
+ @interface Repro (NonPublicApi)
30
+ + (void)_passRuntimeValues:(nonnull NSDictionary<NSString *, NSString *> *)values;
31
+ @end
32
+
33
+
18
34
  @implementation CDVRepro
19
35
 
20
36
  - (void)setup:(CDVInvokedUrlCommand*)command
21
37
  {
38
+ if ([Repro respondsToSelector:@selector(_passRuntimeValues:)]) {
39
+ [Repro _passRuntimeValues:@{
40
+ @"sub_sdk_platform": @"cordova",
41
+ #ifdef CDV_VERSION
42
+ @"sub_sdk_platform_version": CDV_VERSION,
43
+ #endif
44
+ @"sub_sdk_bridge_version": [NSString stringWithUTF8String:REPRO_CORDOVA_BRIDGE_VERSION],
45
+ }];
46
+ }
47
+
22
48
  NSString *key = [command.arguments objectAtIndex:0];
23
49
  [Repro setup:key];
24
50
  }
@@ -585,6 +611,15 @@ static NSDictionary* convertNSStringJSONToNSDictionary(NSString* json) {
585
611
  }];
586
612
  }
587
613
 
614
+ - (void)setOpenUrlCallback:(CDVInvokedUrlCommand*)command
615
+ {
616
+ [Repro setOpenUrlCallback:^void(NSURL *url) {
617
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[url absoluteString]];
618
+ [pluginResult setKeepCallbackAsBool:YES];
619
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
620
+ }];
621
+ }
622
+
588
623
  - (NSString *)convertCampaignTypeToString:(RPRCampaignType)campaignType
589
624
  {
590
625
  switch (campaignType) {
@@ -98,11 +98,11 @@ NS_SWIFT_NAME(value(forKey:));
98
98
  /// Access to remote config values via subscript syntax.
99
99
  - (nonnull RPRRemoteConfigValue *)objectForKeyedSubscript:(nonnull NSString *)key;
100
100
 
101
- /// Return a dictonary with all key value pairs.
101
+ /// Return a dictionary with all key value pairs.
102
102
  - (nonnull NSDictionary<NSString *, RPRRemoteConfigValue *> *)allValues
103
103
  NS_SWIFT_NAME(allValues());
104
104
 
105
- /// Return a dictonary with all key value pairs for a given prefix. Pass `nil` or an empty string to get all values.
105
+ /// Return a dictionary with all key value pairs for a given prefix. Pass `nil` or an empty string to get all values.
106
106
  - (nonnull NSDictionary<NSString *, RPRRemoteConfigValue *> *)allValuesWithPrefix:(nullable NSString *)prefix
107
107
  NS_SWIFT_NAME(allValues(withPrefix:));
108
108
 
@@ -69,6 +69,9 @@ NS_SWIFT_NAME(setUserProfile(emailAddress:));
69
69
 
70
70
 
71
71
  // Event tracking
72
+ + (void)track:(nonnull NSString *)name
73
+ NS_SWIFT_NAME(track(event:));
74
+
72
75
  + (void)track:(nonnull NSString *)name properties:(nullable NSDictionary *)properties
73
76
  NS_SWIFT_NAME(track(event:properties:));
74
77
 
@@ -136,6 +139,16 @@ NS_SWIFT_NAME(set(silverEggCookie:));
136
139
  + (void)setSilverEggProdKey:(nonnull NSString *)silverEggProdKey
137
140
  NS_SWIFT_NAME(set(silverEggProdKey:));
138
141
 
142
+
143
+ // Event Callbacks
144
+
145
+ + (void)addOpenUrlFilterRegEx:(nonnull NSString *)filterRegEx
146
+ NS_SWIFT_NAME(add(openUrlFilterRegEx:));
147
+
148
+ + (void)setOpenUrlCallback:(void(^ _Nullable)(NSURL * _Nonnull url))callback
149
+ NS_SWIFT_NAME(setOpenUrlCallback(_:));
150
+
151
+
139
152
  // Remote Configuration
140
153
  @property (class, nonatomic, readonly, nonnull) RPRRemoteConfig *remoteConfig;
141
154
 
@@ -98,11 +98,11 @@ NS_SWIFT_NAME(value(forKey:));
98
98
  /// Access to remote config values via subscript syntax.
99
99
  - (nonnull RPRRemoteConfigValue *)objectForKeyedSubscript:(nonnull NSString *)key;
100
100
 
101
- /// Return a dictonary with all key value pairs.
101
+ /// Return a dictionary with all key value pairs.
102
102
  - (nonnull NSDictionary<NSString *, RPRRemoteConfigValue *> *)allValues
103
103
  NS_SWIFT_NAME(allValues());
104
104
 
105
- /// Return a dictonary with all key value pairs for a given prefix. Pass `nil` or an empty string to get all values.
105
+ /// Return a dictionary with all key value pairs for a given prefix. Pass `nil` or an empty string to get all values.
106
106
  - (nonnull NSDictionary<NSString *, RPRRemoteConfigValue *> *)allValuesWithPrefix:(nullable NSString *)prefix
107
107
  NS_SWIFT_NAME(allValues(withPrefix:));
108
108
 
@@ -69,6 +69,9 @@ NS_SWIFT_NAME(setUserProfile(emailAddress:));
69
69
 
70
70
 
71
71
  // Event tracking
72
+ + (void)track:(nonnull NSString *)name
73
+ NS_SWIFT_NAME(track(event:));
74
+
72
75
  + (void)track:(nonnull NSString *)name properties:(nullable NSDictionary *)properties
73
76
  NS_SWIFT_NAME(track(event:properties:));
74
77
 
@@ -136,6 +139,16 @@ NS_SWIFT_NAME(set(silverEggCookie:));
136
139
  + (void)setSilverEggProdKey:(nonnull NSString *)silverEggProdKey
137
140
  NS_SWIFT_NAME(set(silverEggProdKey:));
138
141
 
142
+
143
+ // Event Callbacks
144
+
145
+ + (void)addOpenUrlFilterRegEx:(nonnull NSString *)filterRegEx
146
+ NS_SWIFT_NAME(add(openUrlFilterRegEx:));
147
+
148
+ + (void)setOpenUrlCallback:(void(^ _Nullable)(NSURL * _Nonnull url))callback
149
+ NS_SWIFT_NAME(setOpenUrlCallback(_:));
150
+
151
+
139
152
  // Remote Configuration
140
153
  @property (class, nonatomic, readonly, nonnull) RPRRemoteConfig *remoteConfig;
141
154
 
package/www/Repro.js CHANGED
@@ -146,6 +146,10 @@ Repro.prototype.updateNewsFeeds = function (newsFeeds, successCallback, errorCal
146
146
  exec(successCallback, errorCallback, "Repro", "updateNewsFeeds", [newsFeeds]);
147
147
  };
148
148
 
149
+ Repro.prototype.setOpenUrlCallback = function(successCallback, errorCallback) {
150
+ exec(successCallback, errorCallback, "Repro", "setOpenUrlCallback", []);
151
+ };
152
+
149
153
  Repro.prototype.CampaignType = Object.freeze(
150
154
  {
151
155
  InAppMessage: "in_app_message",