Skip to content

Commit

Permalink
Release 5.8.4 (#89)
Browse files Browse the repository at this point in the history
Updated files for 5.8.4 release
  • Loading branch information
HarryAWoodworth authored Apr 13, 2022
1 parent cea9df2 commit 9a9b354
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ This document lets you know what has changed in the Cordova plugin. For changes
- [Android Changelog](https://github.com/apptentive/apptentive-android/blob/master/CHANGELOG.md)
- [iOS Changelog](https://github.com/apptentive/apptentive-ios/blob/master/CHANGELOG.md)

# 2022-04-13 - v5.8.4

**Fixes**
- Add registerWithLogs() to set Apptentive log level
- Add missing callback calls to iOS registration function

- Apptentive Android SDK: 5.8.3
- Apptentive iOS SDK: 5.3.4

# 2022-03-23 - v5.8.3

- Apptentive Android SDK: 5.8.3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apptentive-cordova",
"version": "5.8.3",
"version": "5.8.4",
"description": "Apptentive Plugin For Cordova",
"cordova": {
"id": "apptentive-cordova",
Expand Down
6 changes: 3 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="apptentive-cordova" version="5.8.3">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="apptentive-cordova" version="5.8.4">

<name>Apptentive</name>
<description>Apptentive Plugin For Cordova</description>
Expand Down Expand Up @@ -42,7 +42,7 @@
</config-file>
<config-file target="./res/values/strings.xml" parent="/resources">
<string name="apptentive_distribution">Cordova</string>
<string name="apptentive_distribution_version">5.8.3</string>
<string name="apptentive_distribution_version">5.8.4</string>
</config-file>
<framework src="com.apptentive:apptentive-android:5.8.3"/>
<source-file src="src/android/ApptentiveBridge.java" target-dir="src/com/apptentive/cordova"/>
Expand Down Expand Up @@ -75,7 +75,7 @@
</config-file>

<config-file target="*-Info.plist" parent="ApptentivePluginVersion">
<string>5.8.3</string>
<string>5.8.4</string>
</config-file>

<!-- ApptentiveBridge -->
Expand Down
20 changes: 20 additions & 0 deletions src/android/ApptentiveBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public boolean execute(final String action, JSONArray args, final CallbackContex
@Override
public void run() {
ApptentiveConfiguration configuration = resolveConfiguration(currentActivity.getApplication());

// Parse log level, info by default
String newLogLevel;
try {
newLogLevel = args.getString(0);
} catch (JSONException e) {
newLogLevel = "info";
}
configuration.setLogLevel(parseLogLevel(newLogLevel));

Apptentive.register(currentActivity.getApplication(), configuration);
Application.ActivityLifecycleCallbacks callbacks = ApptentiveActivityLifecycleCallbacks.getInstance();
if (callbacks != null) {
Expand Down Expand Up @@ -292,6 +302,16 @@ public void onLoginFail(String errorMessage) {
return false;
}

private static ApptentiveLog.Level parseLogLevel(String logLevel) {
if (logLevel.equals("verbose")) { return ApptentiveLog.Level.VERBOSE; }
if (logLevel.equals("debug")) { return ApptentiveLog.Level.DEBUG; }
if (logLevel.equals("info")) { return ApptentiveLog.Level.INFO; }
if (logLevel.equals("warn")) { return ApptentiveLog.Level.WARN; }
if (logLevel.equals("error")) { return ApptentiveLog.Level.ERROR; }
if (logLevel.equals("assert")) { return ApptentiveLog.Level.ASSERT; }
return ApptentiveLog.Level.UNKNOWN;
}

private static ApptentiveConfiguration resolveConfiguration(Context context) {
String apptentiveKey = Util.getManifestMetadataString(context, Constants.MANIFEST_KEY_APPTENTIVE_KEY);
if (StringUtils.isNullOrEmpty(apptentiveKey)) {
Expand Down
32 changes: 27 additions & 5 deletions src/ios/ApptentiveBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ - (void)execute:(CDVInvokedUrlCommand *)command {

//initialization
if ([functionCall isEqualToString:@"deviceReady"]) {
[self initAPIKey:callbackId];
// Set log level if present, info level by default
if ([command arguments].count == 2) {
[self initAPIKey:callbackId withLogLevel:[command argumentAtIndex:1]];
} else {
[self initAPIKey:callbackId withLogLevel:@"info"];
}
return;
}
if (!apptentiveInitialized) {
Expand Down Expand Up @@ -107,15 +112,17 @@ - (NSDictionary *)parseDictionaryFromString:(id)value {
}

#pragma mark Initialization and Events
- (void)initAPIKey:(NSString *)callbackId {
- (void)initAPIKey:(NSString *)callbackId withLogLevel:(NSString *)logLevel {
// Access Info.plist for ApptentiveAPIKey
NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];
NSString *apptentiveKey = [infoPlist objectForKey:@"ApptentiveKey"];
NSString *apptentiveSignature = [infoPlist objectForKey:@"ApptentiveSignature"];
NSString *pluginVersion = [infoPlist objectForKey:@"ApptentivePluginVersion"];

// FIXME: Do we really want to be logging this?
NSLog(@"Initializing Apptentive Apptentive App Key: %@, Apptentive App Signature: %@", apptentiveKey, apptentiveSignature);
// Log key and signature with verbose logs
if ([logLevel isEqualToString:@"verbose"]) {
NSLog(@"Initializing Apptentive Apptentive App Key: %@, Apptentive App Signature: %@", apptentiveKey, apptentiveSignature);
}

if (apptentiveKey.length == 0 || apptentiveSignature.length == 0) {
[self sendFailureMessage:@"Insufficient arguments - no API key." callbackId:callbackId];
Expand All @@ -124,14 +131,17 @@ - (void)initAPIKey:(NSString *)callbackId {
if (Apptentive.shared.apptentiveKey.length > 0 && Apptentive.shared.apptentiveSignature.length > 0) {
if (![Apptentive.shared.apptentiveKey isEqualToString:apptentiveKey] || ![Apptentive.shared.apptentiveSignature isEqualToString:apptentiveSignature]) {
NSLog(@"Apptentive key or signature mismatch. The SDK is not initialized.");
[self sendFailureMessage:@"Apptentive key or signature mismatch. The SDK is not initialized." callbackId:callbackId];
return;
}

NSLog(@"WARNING: Apptentive instance is already initialized!");
[self sendFailureMessage:@"Apptentive instance is already initialized." callbackId:callbackId];
return;
} else {
ApptentiveConfiguration *configuration = [ApptentiveConfiguration configurationWithApptentiveKey:apptentiveKey apptentiveSignature:apptentiveSignature];
configuration.distributionName = @"Cordova";
configuration.distributionVersion = pluginVersion;
configuration.logLevel = [self parseLogLevel:logLevel];

[Apptentive registerWithConfiguration:configuration];
}
Expand All @@ -141,6 +151,18 @@ - (void)initAPIKey:(NSString *)callbackId {
if (styleSheetURL != nil) {
Apptentive.shared.styleSheet = [[ApptentiveStyleSheet alloc] initWithContentsOfURL:styleSheetURL];
}

[self sendSuccessMessage:@"Apptentive initialized" callbackId:callbackId];
}

- (ApptentiveLogLevel)parseLogLevel:(NSString *) logLevel {
if ([logLevel isEqualToString:@"verbose"]) { return ApptentiveLogLevelVerbose; }
if ([logLevel isEqualToString:@"debug"]) { return ApptentiveLogLevelDebug; }
if ([logLevel isEqualToString:@"info"]) { return ApptentiveLogLevelInfo; }
if ([logLevel isEqualToString:@"warn"]) { return ApptentiveLogLevelWarn; }
if ([logLevel isEqualToString:@"error"]) { return ApptentiveLogLevelError; }
if ([logLevel isEqualToString:@"critical"]) { return ApptentiveLogLevelCrit; }
return ApptentiveLogLevelUndefined;
}

- (void)registerForMessageNotifications:(NSArray *)arguments callBackString:(NSString *)callbackId {
Expand Down
5 changes: 5 additions & 0 deletions www/ApptentiveAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ var Apptentive = {
cordova.exec(successCallback, errorCallback, "ApptentiveBridge", "deviceReady", []);
},

registerWithLogs: function (successCallback, errorCallback, loglevel) {
console.log("Apptentive.registerWithLogs()");
cordova.exec(successCallback, errorCallback, "ApptentiveBridge", "deviceReady", [loglevel]);
},

engage: function (successCallback, errorCallback, eventName, customData) {
if (customData && typeof customData === 'object') {
cordova.exec(successCallback, errorCallback, "ApptentiveBridge", "engage", [eventName, customData]);
Expand Down
6 changes: 6 additions & 0 deletions www/ApptentiveIos.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ var Apptentive = {
cordova.exec(successCallback, errorCallback, "ApptentiveBridge", "execute", ["deviceReady"]);
},

registerWithLogs: function (successCallback, errorCallback, loglevel) {
console.log("Apptentive.registerWithLogs()");
Apptentive.initialized = true;
cordova.exec(successCallback, errorCallback, "ApptentiveBridge", "execute", ["deviceReady", loglevel]);
},

engage: function (successCallback, errorCallback, eventName, customData) {
if (customData) {
cordova.exec(successCallback, errorCallback, "ApptentiveBridge", "execute", ["engage", eventName, customData]);
Expand Down

0 comments on commit 9a9b354

Please sign in to comment.