diff --git a/.travis.yml b/.travis.yml
index 9f36610..33bb97b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,17 +1,21 @@
language: objective-c
-node_js:
- - 5.10
+node_js: '6.11.2'
sudo: false
+cache:
+ directories:
+ - node_modules
+
install:
+ - npm install -g npm@5.3.0
- npm install -g cordova
before_script:
- cd Example
- - cordova platform add ios
- - cordova plugin add ..
+ - cordova platform add ios
+ - cordova plugin add ../intercom-plugin
script:
- cordova build ios
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32c4559..e7eed3f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Intercom for Cordova/PhoneGap
+## 4.0.0 (2017-08-29)
+
+* Updated Intercom for Android to 4.0.1
+* Updated Intercom for iOS to 4.0.1
+* Removed deprecated method `intercom.setSecureMode(hmac, data)`.
+* Added support for iOS 11.
+* Added support for Android Oreo.
+* Updated GCM & FCM to version 11.
+
## 3.2.2 (2017-05-17)
* Prevent unsafe versions of the Support Library being used to fix [#182](https://github.com/intercom/intercom-cordova/issues/182).
diff --git a/README.md b/README.md
index a45e594..cc9dbf5 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
This is a plugin that allows your Cordova or PhoneGap app to use [Intercom for iOS](https://github.com/intercom/intercom-ios) and/or [Intercom for Android](https://github.com/intercom/intercom-android).
-* Intercom for iOS supports iOS 8, 9 & 10.
+* Intercom for iOS supports iOS 8, 9, 10 & 11.
* Intercom for Android supports API 15 and above.
## Installation
@@ -19,7 +19,7 @@ cordova plugin add cordova-plugin-intercom
To add the plugin to your PhoneGap app, add the following to your `config.xml`:
```xml
-
+
```
### Ionic
diff --git a/circle.yml b/circle.yml
index 90ad67b..86472da 100644
--- a/circle.yml
+++ b/circle.yml
@@ -2,35 +2,38 @@ general:
build_dir: Example
machine:
+ environment:
+ ORG_GRADLE_PROJECT_cdvCompileSdkVersion: android-26
+ ORG_GRADLE_PROJECT_cdvBuildToolsVersion: 26.0.1
node:
- version: 6.1.0
+ version: 6.11.2
java:
version: openjdk8
dependencies:
override:
- npm install -g cordova
- - if [ ! -e $ANDROID_HOME/platforms/android-25 ]; then echo y | android update sdk --no-ui --all --filter android-25; fi
- - if [ ! -e $ANDROID_HOME/extras/android/m2repository/com/android/support/design/25.3.1 ]; then echo y | android update sdk --no-ui --all --filter extra-android-m2repository; fi
- - if [ ! -e $ANDROID_HOME/extras/google/m2repository/com/google/firebase/firebase-messaging/10.2.1 ]; then echo y | android update sdk --no-ui --all --filter extra-google-m2repository; fi
+ # Need to always update these 2 to accept licenses
+ - echo y | android update sdk --no-ui --all --filter android-25
+ - echo y | android update sdk --no-ui --all --filter android-26
+ - if [ ! -e $ANDROID_HOME/build-tools/26.0.1 ]; then echo y | android update sdk --no-ui --all --filter build-tools-26.0.1; fi
+ - if [ ! -e $ANDROID_HOME/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.4 ]; then echo y | android update sdk --no-ui --all --filter extra-google-m2repository; fi
cache_directories:
# Android SDK
- - "/usr/local/android-sdk-linux/platforms/android-24"
- - "/usr/local/android-sdk-linux/extras/android/m2repository"
+ - "/usr/local/android-sdk-linux/build-tools/26.0.1"
- "/usr/local/android-sdk-linux/extras/google/m2repository"
-
+
test:
- pre:
- - cordova platform add android
- - cordova plugin add ..
override:
- - cordova build android
+ - cordova platform add android
+ - cordova plugin add ../intercom-plugin
+ - cordova build android --verbose -- --gradleArg=--stacktrace
deployment:
master:
- tag: /3(\.[0-9]+)+/
+ tag: /[0-9](\.[0-9]+)+/
owner: intercom
commands:
- echo -e "$NPM_USER\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
- - cd .. && npm publish
+ - cd ../intercom-plugin && npm publish
diff --git a/package.json b/intercom-plugin/package.json
similarity index 97%
rename from package.json
rename to intercom-plugin/package.json
index 1e5073c..03dab9a 100644
--- a/package.json
+++ b/intercom-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-intercom",
- "version": "3.2.2",
+ "version": "4.0.0",
"description": "Official Cordova/PhoneGap plugin for Intercom",
"cordova": {
"id": "cordova-plugin-intercom",
diff --git a/plugin.xml b/intercom-plugin/plugin.xml
similarity index 96%
rename from plugin.xml
rename to intercom-plugin/plugin.xml
index b8f447d..3c66528 100644
--- a/plugin.xml
+++ b/intercom-plugin/plugin.xml
@@ -1,5 +1,5 @@
-
+
Intercom
Intercom
MIT License
@@ -47,7 +47,7 @@
-
+
diff --git a/scripts/checkForUpdate.js b/intercom-plugin/scripts/checkForUpdate.js
similarity index 100%
rename from scripts/checkForUpdate.js
rename to intercom-plugin/scripts/checkForUpdate.js
diff --git a/scripts/prepareCocoaPods.js b/intercom-plugin/scripts/prepareCocoaPods.js
similarity index 100%
rename from scripts/prepareCocoaPods.js
rename to intercom-plugin/scripts/prepareCocoaPods.js
diff --git a/src/android/CordovaHeaderInterceptor.java b/intercom-plugin/src/android/CordovaHeaderInterceptor.java
similarity index 100%
rename from src/android/CordovaHeaderInterceptor.java
rename to intercom-plugin/src/android/CordovaHeaderInterceptor.java
diff --git a/src/android/IntercomBridge.java b/intercom-plugin/src/android/IntercomBridge.java
similarity index 94%
rename from src/android/IntercomBridge.java
rename to intercom-plugin/src/android/IntercomBridge.java
index 3d1ac18..0ae1850 100644
--- a/src/android/IntercomBridge.java
+++ b/intercom-plugin/src/android/IntercomBridge.java
@@ -34,6 +34,8 @@
public class IntercomBridge extends CordovaPlugin {
+ private static final String CUSTOM_ATTRIBUTES = "custom_attributes";
+
@Override protected void pluginInitialize() {
cordova.getActivity().runOnUiThread(new Runnable() {
@Override public void run() {
@@ -66,7 +68,7 @@ private void setUpIntercom() {
try {
Context context = IntercomBridge.this.cordova.getActivity().getApplicationContext();
- CordovaHeaderInterceptor.setCordovaVersion(context, "3.2.2");
+ CordovaHeaderInterceptor.setCordovaVersion(context, "4.0.0");
switch (IntercomPushManager.getInstalledModuleType()) {
case GCM: {
@@ -121,14 +123,6 @@ private enum Action {
callbackContext.success();
}
},
- setSecureMode {
- @Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
- String hmac = args.optString(0);
- String data = args.optString(1);
- Intercom.client().setSecureMode(hmac, data);
- callbackContext.success();
- }
- },
setUserHash {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
String hmac = args.optString(0);
@@ -212,7 +206,15 @@ private enum Action {
updateUser {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
Map attributes = IntercomBridge.mapFromJSON(args.optJSONObject(0));
- Intercom.client().updateUser(attributes);
+ UserAttributes.Builder builder = new UserAttributes.Builder();
+ Object customAttributes = attributes.get(CUSTOM_ATTRIBUTES);
+ if (customAttributes instanceof Map) {
+ //noinspection unchecked
+ builder.customAttributes.putAll((Map extends String, ?>) customAttributes);
+ }
+ attributes.remove(CUSTOM_ATTRIBUTES);
+ builder.attributes.putAll(attributes);
+ Intercom.client().updateUser(builder.build());
callbackContext.success();
}
},
diff --git a/src/android/IntercomIntentService.java b/intercom-plugin/src/android/IntercomIntentService.java
similarity index 100%
rename from src/android/IntercomIntentService.java
rename to intercom-plugin/src/android/IntercomIntentService.java
diff --git a/src/android/build-extras-intercom.gradle b/intercom-plugin/src/android/build-extras-intercom.gradle
similarity index 96%
rename from src/android/build-extras-intercom.gradle
rename to intercom-plugin/src/android/build-extras-intercom.gradle
index 4d38f4b..13fad84 100644
--- a/src/android/build-extras-intercom.gradle
+++ b/intercom-plugin/src/android/build-extras-intercom.gradle
@@ -9,7 +9,7 @@ android.defaultConfig.applicationId manifest.@package.text()
// some libraries depend on higher versions of our dependencies than we support
// we keep track of these dependencies here and override the version to a safe one
def safeVersions = [
- "com.android.support:support-v4": "25.+"
+ "com.android.support:support-v4": "26.+"
]
def badVersionIndicators = [
diff --git a/src/android/intercom.gradle b/intercom-plugin/src/android/intercom.gradle
similarity index 67%
rename from src/android/intercom.gradle
rename to intercom-plugin/src/android/intercom.gradle
index 972da3f..68561ed 100644
--- a/src/android/intercom.gradle
+++ b/intercom-plugin/src/android/intercom.gradle
@@ -10,9 +10,10 @@ buildscript {
repositories {
jcenter()
mavenLocal()
+ maven { url 'https://maven.google.com' }
}
dependencies {
- classpath 'com.android.tools.build:gradle:+'
+ classpath 'com.android.tools.build:gradle:2.3.+'
if (pushType == 'fcm') {
classpath 'com.google.gms:google-services:3.0.0'
}
@@ -21,14 +22,15 @@ buildscript {
repositories {
jcenter()
+ maven { url 'https://maven.google.com' }
}
dependencies {
- compile 'io.intercom.android:intercom-sdk-base:3.2.+'
+ compile 'io.intercom.android:intercom-sdk-base:4.0.+'
if (pushType == 'gcm') {
- compile 'io.intercom.android:intercom-sdk-gcm:3.2.+'
+ compile 'io.intercom.android:intercom-sdk-gcm:4.0.+'
} else if (pushType == 'fcm') {
- compile 'com.google.firebase:firebase-messaging:10.+'
- compile 'io.intercom.android:intercom-sdk-fcm:3.2.+'
+ compile 'com.google.firebase:firebase-messaging:11.+'
+ compile 'io.intercom.android:intercom-sdk-fcm:4.0.+'
}
}
diff --git a/src/ios/AppDelegate+IntercomPush.h b/intercom-plugin/src/ios/AppDelegate+IntercomPush.h
similarity index 100%
rename from src/ios/AppDelegate+IntercomPush.h
rename to intercom-plugin/src/ios/AppDelegate+IntercomPush.h
diff --git a/src/ios/AppDelegate+IntercomPush.m b/intercom-plugin/src/ios/AppDelegate+IntercomPush.m
similarity index 100%
rename from src/ios/AppDelegate+IntercomPush.m
rename to intercom-plugin/src/ios/AppDelegate+IntercomPush.m
diff --git a/src/ios/IntercomBridge.h b/intercom-plugin/src/ios/IntercomBridge.h
similarity index 94%
rename from src/ios/IntercomBridge.h
rename to intercom-plugin/src/ios/IntercomBridge.h
index ce79332..58aeae9 100644
--- a/src/ios/IntercomBridge.h
+++ b/intercom-plugin/src/ios/IntercomBridge.h
@@ -8,7 +8,7 @@
- (void)registerUnidentifiedUser:(CDVInvokedUrlCommand*)command;
- (void)reset:(CDVInvokedUrlCommand*)command;
-- (void)setSecureMode:(CDVInvokedUrlCommand*)command;
+- (void)setUserHash:(CDVInvokedUrlCommand*)command;
- (void)updateUser:(CDVInvokedUrlCommand*)command;
- (void)logEvent:(CDVInvokedUrlCommand*)command;
diff --git a/src/ios/IntercomBridge.m b/intercom-plugin/src/ios/IntercomBridge.m
similarity index 53%
rename from src/ios/IntercomBridge.m
rename to intercom-plugin/src/ios/IntercomBridge.m
index 9865c49..15580bd 100644
--- a/src/ios/IntercomBridge.m
+++ b/intercom-plugin/src/ios/IntercomBridge.m
@@ -9,7 +9,7 @@ + (void)setCordovaVersion:(NSString *)v;
@implementation IntercomBridge : CDVPlugin
- (void)pluginInitialize {
- [Intercom setCordovaVersion:@"3.2.2"];
+ [Intercom setCordovaVersion:@"4.0.0"];
#ifdef DEBUG
[Intercom enableLogging];
#endif
@@ -56,14 +56,6 @@ - (void)reset:(CDVInvokedUrlCommand*)command {
[self sendSuccess:command];
}
-- (void)setSecureMode:(CDVInvokedUrlCommand*)command {
- NSString *hmac = command.arguments[0];
- NSString *data = command.arguments[1];
-
- [Intercom setHMAC:hmac data:data];
- [self sendSuccess:command];
-}
-
- (void)setUserHash:(CDVInvokedUrlCommand*)command {
NSString *hmac = command.arguments[0];
@@ -72,9 +64,8 @@ - (void)setUserHash:(CDVInvokedUrlCommand*)command {
}
- (void)updateUser:(CDVInvokedUrlCommand*)command {
- NSDictionary* attributes = command.arguments[0];
- [Intercom updateUserWithAttributes:attributes];
-
+ NSDictionary* attributesDict = command.arguments[0];
+ [Intercom updateUser:[self userAttributesForDictionary:attributesDict]];
[self sendSuccess:command];
}
@@ -153,6 +144,104 @@ - (void)registerForPush:(CDVInvokedUrlCommand*)command {
[self sendSuccess:command];
}
+#pragma mark - User attributes
+
+- (ICMUserAttributes *)userAttributesForDictionary:(NSDictionary *)attributesDict {
+ ICMUserAttributes *attributes = [ICMUserAttributes new];
+ if ([self stringValueForKey:@"email" inDictionary:attributesDict]) {
+ attributes.email = [self stringValueForKey:@"email" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"user_id" inDictionary:attributesDict]) {
+ attributes.userId = [self stringValueForKey:@"user_id" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"name" inDictionary:attributesDict]) {
+ attributes.name = [self stringValueForKey:@"name" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"phone" inDictionary:attributesDict]) {
+ attributes.phone = [self stringValueForKey:@"phone" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"language_override" inDictionary:attributesDict]) {
+ attributes.languageOverride = [self stringValueForKey:@"language_override" inDictionary:attributesDict];
+ }
+ if ([self dateValueForKey:@"signed_up_at" inDictionary:attributesDict]) {
+ attributes.signedUpAt = [self dateValueForKey:@"signed_up_at" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"unsubscribed_from_emails" inDictionary:attributesDict]) {
+ attributes.unsubscribedFromEmails = [self stringValueForKey:@"unsubscribed_from_emails" inDictionary:attributesDict];
+ }
+ if (attributesDict[@"custom_attributes"]) {
+ attributes.customAttributes = attributesDict[@"custom_attributes"];
+ }
+ if (attributesDict[@"companies"]) {
+ NSMutableArray *companies = [NSMutableArray new];
+ for (NSDictionary *companyDict in attributesDict[@"companies"]) {
+ [companies addObject:[self companyForDictionary:companyDict]];
+ }
+ attributes.companies = companies;
+ }
+ return attributes;
+}
+
+- (ICMCompany *)companyForDictionary:(NSDictionary *)attributesDict {
+ ICMCompany *company = [ICMCompany new];
+ if ([self stringValueForKey:@"company_id" inDictionary:attributesDict]) {
+ company.companyId = [self stringValueForKey:@"company_id" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"name" inDictionary:attributesDict]) {
+ company.name = [self stringValueForKey:@"name" inDictionary:attributesDict];
+ }
+ if ([self dateValueForKey:@"created_at" inDictionary:attributesDict]) {
+ company.createdAt = [self dateValueForKey:@"created_at" inDictionary:attributesDict];
+ }
+ if ([self numberValueForKey:@"monthly_spend" inDictionary:attributesDict]) {
+ company.monthlySpend = [self numberValueForKey:@"monthly_spend" inDictionary:attributesDict];
+ }
+ if ([self stringValueForKey:@"plan" inDictionary:attributesDict]) {
+ company.plan = [self stringValueForKey:@"plan" inDictionary:attributesDict];
+ }
+ if (attributesDict[@"custom_attributes"]) {
+ company.customAttributes = attributesDict[@"custom_attributes"];
+ }
+ return company;
+}
+
+- (NSString *)stringValueForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
+ NSString *value = dictionary[key];
+ if ([value isKindOfClass:[NSString class]]) {
+ return value;
+ }
+ if ([value isKindOfClass:[NSNumber class]]) {
+ return [NSString stringWithFormat:@"%@", value];
+ }
+ if ([value isKindOfClass:[NSNull class]]) {
+ return [ICMUserAttributes nullStringAttribute];
+ }
+ return nil;
+}
+
+- (NSNumber *)numberValueForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
+ NSNumber *value = dictionary[key];
+ if ([value isKindOfClass:[NSNumber class]]) {
+ return value;
+ }
+ if ([value isKindOfClass:[NSNull class]]) {
+ return [ICMUserAttributes nullNumberAttribute];
+ }
+ return nil;
+}
+
+- (NSDate *)dateValueForKey:(NSString *)key inDictionary:(NSDictionary *)dictionary {
+ NSNumber *value = dictionary[key];
+ if ([value isKindOfClass:[NSNumber class]]) {
+ return [NSDate dateWithTimeIntervalSince1970:[value doubleValue]];
+ }
+ if ([value isKindOfClass:[NSNull class]]) {
+ return [ICMUserAttributes nullDateAttribute];
+ }
+ return nil;
+}
+
+
#pragma mark - Private methods
- (void)sendSuccess:(CDVInvokedUrlCommand*)command {
diff --git a/www/intercom.js b/intercom-plugin/www/intercom.js
similarity index 100%
rename from www/intercom.js
rename to intercom-plugin/www/intercom.js