Skip to content

Commit

Permalink
Release 14.0.3 (#337)
Browse files Browse the repository at this point in the history
* Bumped iOS and have first API working

* Have first API working for Android

* Now working with new APIs on both platforms

* Fixed extraneous comma

* Bumped version and added release notes

* Package lock
  • Loading branch information
mapierce authored Dec 11, 2024
1 parent eb5d78a commit ed71fb1
Show file tree
Hide file tree
Showing 21 changed files with 187 additions and 69 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Intercom for Cordova/PhoneGap

## 14.0.3 (2024-12-11)

🐛 Bug Fixes
* Solves a crash in carousels. (iOS)
* Addressed issue where video input wasn’t available in a conversation. (iOS)
* Fixes issue where first part in a conversation would fail to show as failed in the scenario where it didn’t send. (iOS)
* Resolved some layout issues in the conversation screen for users with large font sizes enabled. (iOS)
* Fixed the bug where users were unable to add a phone number in the attribute collector. (Android)
* Fixed a crash caused by `IllegalArgumentException: y must be < bitmap.height()`. (Android)

## 14.0.2 (2024-06-25)

🐛 Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions Example/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<hook type="after_platform_add" src="hooks/iosDeploymentTarget.js" />
<platform name="android">
<allow-intent href="market:*" />
<preference name="android-minSdkVersion" value="22" />
Expand Down
17 changes: 17 additions & 0 deletions Example/hooks/iosDeploymentTarget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const path = require('path');

module.exports = function (context) {
const platformRoot = path.join(context.opts.projectRoot, 'platforms/ios');
const projectPbxproj = path.join(platformRoot, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj');

if (fs.existsSync(projectPbxproj)) {
let contents = fs.readFileSync(projectPbxproj, 'utf8');

// Update deployment target
contents = contents.replace(/IPHONEOS_DEPLOYMENT_TARGET = 11\.0;/g, 'IPHONEOS_DEPLOYMENT_TARGET = 15.0;');

fs.writeFileSync(projectPbxproj, contents, 'utf8');
console.log('Updated CordovaLib deployment target to iOS 15.0');
}
};
8 changes: 4 additions & 4 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"cordova-plugin-intercom": {}
}
},
"dependencies": {
"cordova-android": "13.0.0",
"cordova-ios": "^7.1.0"
},
"devDependencies": {
"cordova-plugin-intercom": "file:../intercom-plugin"
},
"dependencies": {
"cordova-android": "13.0.0",
"cordova-ios": "7.1.1"
}
}
2 changes: 1 addition & 1 deletion Example/www/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ body {
padding:0px;
text-transform:uppercase;
width:100%;
overflow: hidden;
overflow: scroll;
}

/* Portrait layout (default) */
Expand Down
2 changes: 2 additions & 0 deletions Example/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<p><button id="help-center-data-api-fetch-btn">Fetch collections</button></p>
<p><button id="help-center-data-api-fetch-content-btn">Fetch collection content</button></p>
<p><button id="help-center-data-api-search-btn">Search help center</button></p>
<p><button id="is-user-logged-in-btn">Check if user is logged in</button></p>
<p><button id="fetch-logged-in-attributes-btn">Fetch logged in user attribtues</button></p>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
Expand Down
22 changes: 21 additions & 1 deletion Example/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,27 @@ var app = {
// Replace this with your own conversation Id
var conversation = intercomContent.conversationWithConversationId('CONVERSATION_ID')
intercom.presentContent(conversation);
}, false);
}, false);

document.getElementById("is-user-logged-in-btn").addEventListener("click", function(){
var onSuccess = function(data) {
console.log('User logged in status: ' + data);
}
var onError = function(code) {
console.log('Failed to fetch logged in status :' + code);
}
intercom.isUserLoggedIn(onSuccess, onError);
}, false);

document.getElementById("fetch-logged-in-attributes-btn").addEventListener("click", function(){
var onSuccess = function(data) {
console.log('Successfully fetched logged in attributes: ' + data);
}
var onError = function(code) {
console.log('Failed to fetch logged in attributes: ' + code);
}
intercom.fetchLoggedInUserAttributes(onSuccess, onError);
}, false);
},
// Update DOM on a Received Event
receivedEvent: function(id) {
Expand Down
4 changes: 2 additions & 2 deletions intercom-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion intercom-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-intercom",
"version": "14.0.2",
"version": "14.0.3",
"description": "Official Cordova plugin for Intercom",
"author": "Intercom",
"license": "MIT License",
Expand Down
10 changes: 5 additions & 5 deletions intercom-plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<engines>
<engine name="cordova" version=">=12.0.0" />
<engine name="cordova-android" version=">=13.0.0" />
<engine name="cordova-ios" version="7.1.0" />
<engine name="cordova-ios" version="7.1.1" />
</engines>

<js-module name="Intercom" src="www/intercom.js">
Expand Down Expand Up @@ -40,9 +40,8 @@
<source-file src="src/ios/ICMHelpCenterArticle+DictionaryConversion.m" />
<source-file src="src/ios/ICMHelpCenterCollectionContent+DictionaryConversion.h" />
<source-file src="src/ios/ICMHelpCenterCollectionContent+DictionaryConversion.m" />
<source-file src="src/ios/ICMHelpCenterSection+DictionaryConversion.h" />
<source-file src="src/ios/ICMHelpCenterSection+DictionaryConversion.m" />

<source-file src="src/ios/ICMUserAttributes+DictionaryConversion.h" />
<source-file src="src/ios/ICMUserAttributes+DictionaryConversion.m" />
<header-file src="src/ios/AppDelegate+IntercomPush.h" />
<source-file src="src/ios/AppDelegate+IntercomPush.m" />

Expand All @@ -69,7 +68,7 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Intercom" spec="~> 17.1.2" />
<pod name="Intercom" spec="~> 18.2.1" />
</pods>
</podspec>
</platform>
Expand All @@ -79,6 +78,7 @@
<source-file src="src/android/HelpCenterCollectionModel.java" target-dir="src/io/intercom/android/sdk" />
<source-file src="src/android/HelpCenterCollectionContentModel.java" target-dir="src/io/intercom/android/sdk" />
<source-file src="src/android/HelpCenterCollectionSectionModel.java" target-dir="src/io/intercom/android/sdk" />
<source-file src="src/android/RegistrationModel.java" target-dir="src/io/intercom/android/sdk" />
<source-file src="src/android/CordovaHeaderInterceptor.java" target-dir="src/io/intercom/android/sdk" />

<framework src="src/android/intercom.gradle" custom="true" type="gradleReference" />
Expand Down
18 changes: 18 additions & 0 deletions intercom-plugin/src/android/IntercomBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ public void onFailure(IntercomError intercomError) {
callbackContext.success();
}
},
isUserLoggedIn {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
boolean loggedIn = Intercom.client().isUserLoggedIn();
callbackContext.success(loggedIn ? "true" : "false");
}
},
fetchLoggedInUserAttributes {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
Registration registration = Intercom.client().fetchLoggedInUserAttributes();
if (registration != null) {
RegistrationModel responseModel = new RegistrationModel(registration.getEmail(), registration.getUserId());
String json = new Gson().toJson(responseModel);
callbackContext.success(json);
} else {
callbackContext.error("No user is currently logged in");
}
}
},
setUserHash {
@Override void performAction(JSONArray args, CallbackContext callbackContext, CordovaInterface cordova) {
String hmac = args.optString(0);
Expand Down
14 changes: 14 additions & 0 deletions intercom-plugin/src/android/RegistrationModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.intercom.android.sdk;

public class RegistrationModel {
private String email;
private String userId;

public RegistrationModel(
String email,
String userId
) {
this.email = email;
this.userId = userId;
}
}
4 changes: 2 additions & 2 deletions intercom-plugin/src/android/intercom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ repositories {
}

dependencies {
implementation 'io.intercom.android:intercom-sdk-base:15.9.1'
implementation 'io.intercom.android:intercom-sdk-base:15.11.3'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.intercom:twig:1.3.0'
implementation 'org.jetbrains:annotations:13.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
if (pushType == 'fcm' || pushType == 'fcm-without-build-plugin') {
implementation 'com.google.firebase:firebase-messaging:20.+'
implementation 'io.intercom.android:intercom-sdk-fcm:15.9.1'
implementation 'io.intercom.android:intercom-sdk-fcm:15.11.3'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2021 Intercom. All rights reserved.
//

#import "ICMHelpCenterSection+DictionaryConversion.h"
#import "ICMHelpCenterCollection+DictionaryConversion.h"
#import "ICMHelpCenterArticle+DictionaryConversion.h"
#import "ICMHelpCenterCollectionContent+DictionaryConversion.h"

Expand All @@ -25,12 +25,12 @@ - (NSDictionary *)toDictionary {
}
[dictionary setValue:arrayOfArticleDictionaries forKey:@"articles"];

NSMutableArray *arrayOfSectionDictionaries = [@[] mutableCopy];
for (ICMHelpCenterSection *section in self.sections) {
NSDictionary *sectionDictionary = [section toDictionary];
[arrayOfSectionDictionaries addObject:sectionDictionary];
NSMutableArray *arrayOfCollectionDictionaries = [@[] mutableCopy];
for (ICMHelpCenterCollection *collection in self.collections) {
NSDictionary *collectionDictionary = [collection toDictionary];
[arrayOfCollectionDictionaries addObject:collectionDictionary];
}
[dictionary setValue:arrayOfSectionDictionaries forKey:@"sections"];
[dictionary setValue:arrayOfCollectionDictionaries forKey:@"collections"];

return [dictionary copy];
}
Expand Down

This file was deleted.

This file was deleted.

19 changes: 19 additions & 0 deletions intercom-plugin/src/ios/ICMUserAttributes+DictionaryConversion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ICMUserAttributes+DictionaryConversion.h
// Sample
//
// Created by Matthew Pierce on 11/12/2024.
// Copyright © 2024 Intercom. All rights reserved.
//

#import "Intercom/Intercom.h"

NS_ASSUME_NONNULL_BEGIN

@interface ICMUserAttributes (DictionaryConversion)

- (NSDictionary *)toDictionary;

@end

NS_ASSUME_NONNULL_END
24 changes: 24 additions & 0 deletions intercom-plugin/src/ios/ICMUserAttributes+DictionaryConversion.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ICMUserAttributes+DictionaryConversion.h
// Sample
//
// Created by Matthew Pierce on 11/12/2024.
// Copyright © 2024 Intercom. All rights reserved.
//

#import "ICMUserAttributes+DictionaryConversion.h"

@implementation ICMUserAttributes (DictionaryConversion)

- (NSDictionary *)toDictionary {
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
if (self.email) {
dictionary[@"email"] = self.email;
}
if (self.userId) {
dictionary[@"userId"] = self.userId;
}
return [dictionary copy];
}

@end
5 changes: 5 additions & 0 deletions intercom-plugin/src/ios/IntercomBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
- (void)setUserHash:(CDVInvokedUrlCommand*)command;
- (void)updateUser:(CDVInvokedUrlCommand*)command;

#pragma mark - Logged in status

- (void)isUserLoggedIn:(CDVInvokedUrlCommand*)command;
- (void)fetchLoggedInUserAttributes:(CDVInvokedUrlCommand*)command;

#pragma mark - Events

- (void)logEvent:(CDVInvokedUrlCommand*)command;
Expand Down
19 changes: 19 additions & 0 deletions intercom-plugin/src/ios/IntercomBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "ICMHelpCenterCollection+DictionaryConversion.h"
#import "ICMHelpCenterArticleSearchResult+DictionaryConversion.h"
#import "ICMHelpCenterCollectionContent+DictionaryConversion.h"
#import "ICMUserAttributes+DictionaryConversion.h"
#import <Intercom/Intercom.h>

@interface Intercom (Cordoava)
Expand Down Expand Up @@ -82,6 +83,24 @@ - (void)logout:(CDVInvokedUrlCommand*)command {
[self sendSuccess:command];
}

- (void)isUserLoggedIn:(CDVInvokedUrlCommand*)command {
BOOL loggedIn = [Intercom isUserLoggedIn];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:loggedIn];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)fetchLoggedInUserAttributes:(CDVInvokedUrlCommand*)command {
ICMUserAttributes *attributes = [Intercom fetchLoggedInUserAttributes];
if (attributes) {
NSString *jsonString = [self stringValueForDictionary:[attributes toDictionary]];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsNSInteger:command.callbackId];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
}

- (void)updateUser:(CDVInvokedUrlCommand*)command {
NSDictionary* attributesDict = command.arguments[0];
[Intercom updateUser:[self userAttributesForDictionary:attributesDict] success:^{
Expand Down
Loading

0 comments on commit ed71fb1

Please sign in to comment.