Skip to content

Commit

Permalink
add user hash method to public api for identity verification (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaleCantwell authored Apr 25, 2017
1 parent 517b080 commit 6ff82fb
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Intercom for Cordova/PhoneGap

## 3.2.0 (2017-04-21)

* Added a new method to the API `intercom.setUserHash(userHash)` to support Identity Verification. This method replaces `intercom.setSecureMode(hmac, data)` which was used for our previous security feature Secure Mode.
* Updated Intercom for Android to 3.2.x.
* Updated Intercom for iOS to 3.2.x.

## 3.1.3 (2017-04-05)

* Added hook to ensure the local CocoaPods specs repo is up to date when installing the plugin (see [#170](https://github.com/intercom/intercom-cordova/pull/170)).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<plugin name="cordova-plugin-intercom" version="~3.1.3" />
<plugin name="cordova-plugin-intercom" version="~3.2.0" />
```
### Ionic

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": "cordova-plugin-intercom",
"version": "3.1.3",
"version": "3.2.0",
"description": "Official Cordova/PhoneGap plugin for Intercom",
"cordova": {
"id": "cordova-plugin-intercom",
Expand Down
4 changes: 2 additions & 2 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 id="cordova-plugin-intercom" version="3.1.3" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="cordova-plugin-intercom" version="3.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>Intercom</name>
<author>Intercom</author>
<license>MIT License</license>
Expand Down Expand Up @@ -47,7 +47,7 @@
</array>
</config-file>

<framework src="Intercom" type="podspec" spec="~> 3.1.3" />
<framework src="Intercom" type="podspec" spec="~> 3.2.0" />
</platform>

<platform name="android">
Expand Down
9 changes: 8 additions & 1 deletion src/android/IntercomBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void setUpIntercom() {
try {
Context context = IntercomBridge.this.cordova.getActivity().getApplicationContext();

CordovaHeaderInterceptor.setCordovaVersion(context, "3.1.3");
CordovaHeaderInterceptor.setCordovaVersion(context, "3.2.0");

switch (IntercomPushManager.getInstalledModuleType()) {
case GCM: {
Expand Down Expand Up @@ -129,6 +129,13 @@ private enum Action {
callbackContext.success();
}
},
setUserHash {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
String hmac = args.optString(0);
Intercom.client().setUserHash(hmac);
callbackContext.success();
}
},
logEvent {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
String eventName = args.optString(0);
Expand Down
6 changes: 3 additions & 3 deletions src/android/intercom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ repositories {
jcenter()
}
dependencies {
compile 'io.intercom.android:intercom-sdk-base:3.1.+'
compile 'io.intercom.android:intercom-sdk-base:3.2.+'
if (pushType == 'gcm') {
compile 'io.intercom.android:intercom-sdk-gcm:3.1.+'
compile 'io.intercom.android:intercom-sdk-gcm:3.2.+'
} else if (pushType == 'fcm') {
compile 'com.google.firebase:firebase-messaging:10.+'
compile 'io.intercom.android:intercom-sdk-fcm:3.1.+'
compile 'io.intercom.android:intercom-sdk-fcm:3.2.+'
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/ios/IntercomBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ + (void)setCordovaVersion:(NSString *)v;
@implementation IntercomBridge : CDVPlugin

- (void)pluginInitialize {
[Intercom setCordovaVersion:@"3.1.3"];
[Intercom setCordovaVersion:@"3.2.0"];
#ifdef DEBUG
[Intercom enableLogging];
#endif
Expand Down Expand Up @@ -64,6 +64,13 @@ - (void)setSecureMode:(CDVInvokedUrlCommand*)command {
[self sendSuccess:command];
}

- (void)setUserHash:(CDVInvokedUrlCommand*)command {
NSString *hmac = command.arguments[0];

[Intercom setUserHash:hmac];
[self sendSuccess:command];
}

- (void)updateUser:(CDVInvokedUrlCommand*)command {
NSDictionary* attributes = command.arguments[0];
[Intercom updateUserWithAttributes:attributes];
Expand Down
4 changes: 4 additions & 0 deletions www/intercom.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ var intercom = {
cordova.exec(success, error, 'Intercom', 'setSecureMode', [secureHash, secureData]);
},

setUserHash: function(secureHash, success, error) {
cordova.exec(success, error, 'Intercom', 'setUserHash', [secureHash]);
},

updateUser: function(attributes, success, error) {
cordova.exec(success, error, 'Intercom', 'updateUser', [attributes]);
},
Expand Down

0 comments on commit 6ff82fb

Please sign in to comment.