Skip to content

Commit

Permalink
Update to the latest Intercom iOS SDK (#329)
Browse files Browse the repository at this point in the history
Updated to use the latest Intercom iOS SDK.
This required a lot of updates to the JS API.
Deprecated a lot of methods, but these will continue to work. They will however be removed in a future release, therefore it is recommended to adopt the new API.
  • Loading branch information
Br1an-Boyle authored May 30, 2024
1 parent a005f45 commit 0455839
Show file tree
Hide file tree
Showing 15 changed files with 751 additions and 285 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
Example/node_modules
intercom-cordova.code-workspace
2 changes: 1 addition & 1 deletion Example/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.6
3.3.0
4 changes: 2 additions & 2 deletions Example/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<preference name="deployment-target" value="13.0" />
<preference name="deployment-target" value="15.0" />
<preference name="BackupWebStorage" value="local" />
<icon height="29" src="www/img/icon-29.png" width="29" />
<icon height="58" src="www/img/[email protected]" width="58" />
Expand All @@ -47,7 +47,7 @@
<icon height="80" src="www/img/[email protected]" width="80" />
<icon height="167" src="www/img/[email protected]" width="167" />
</platform>
<preference name="intercom-app-id" value="YOUR_APP_ID" />
<preference name="intercom-app-id" value="YOUR_WORKSPACE_ID" />
<preference name="intercom-ios-api-key" value="YOUR_IOS_API_KEY" />
<preference name="intercom-android-api-key" value="YOUR_ANDROID_API_KEY" />

Expand Down
447 changes: 309 additions & 138 deletions Example/package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"dependencies": {
"cordova-android": "^10.1.1",
"cordova-ios": "6.2.0"
"cordova-ios": "7.1.0"
},
"devDependencies": {
"cordova-plugin-intercom": "file:../intercom-plugin"
}
}
}
7 changes: 4 additions & 3 deletions Example/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
<p><button id="login-btn">Login</button></p>
<p><button id="logout-btn">Logout</button></p>
<p><button id="open-intercom-btn">Open Intercom</button></p>
<p><button id="display-carousel-btn">Display Carousel</button></p>
<p><button id="display-article-btn">Display Article</button></p>
<p><button id="display-survey-btn">Display Survey</button></p>
<p><button id="display-carousel-btn">Present Carousel</button></p>
<p><button id="display-article-btn">Present Article</button></p>
<p><button id="display-survey-btn">Present Survey</button></p>
<p><button id="display-conversation-btn">Present Conversation</button></p>
<p><button id="open-help-center-btn">Open Help Center</button></p>
<p><button id="open-help-center-filtered-btn">Open Filtered Help Center</button></p>
<p>Help Center Data API</p>
Expand Down
29 changes: 22 additions & 7 deletions Example/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ var app = {
}, false);

document.getElementById("open-intercom-btn").addEventListener("click", function(){
intercom.displayMessenger();
intercom.present();
}, false);

document.getElementById("open-help-center-btn").addEventListener("click", function(){
intercom.displayHelpCenter();
intercom.presentSpace(intercom.Space.HelpCenter);
}, false);

document.getElementById("open-help-center-filtered-btn").addEventListener("click", function(){
// Replace this with your own collections
var ids = ["COLLECTION_ID1", "COLLECTION_ID2"];
var collectionIds = ["COLLECTION_ID1", "COLLECTION_ID2"];

intercom.displayHelpCenterCollections({collectionIds: ids});
}, false);

Expand Down Expand Up @@ -103,16 +104,28 @@ var app = {
}, false);

document.getElementById("display-carousel-btn").addEventListener("click", function(){
intercom.displayCarousel("carousel-id");
// Replace this with your own carousel Id
var carousel = intercomContent.carouselWithCarouselId('CAROUSEL_ID')
intercom.presentContent(carousel)
}, false);

document.getElementById("display-article-btn").addEventListener("click", function(){
intercom.displayArticle("article-id");
// Replace this with your own article Id
var article = intercomContent.articleWithArticleId('ARTICLE_ID')
intercom.presentContent(article);
}, false);

document.getElementById("display-survey-btn").addEventListener("click", function(){
intercom.displaySurvey("survey-id");
document.getElementById("display-survey-btn").addEventListener("click", function(){
// Replace this with your own survey Id
var survey = intercomContent.surveyWithSurveyId('SURVEY_ID')
intercom.presentContent(survey);
}, false);

document.getElementById("display-conversation-btn").addEventListener("click", function(){
// Replace this with your own conversation Id
var conversation = intercomContent.conversationWithConversationId('CONVERSATION_ID')
intercom.presentContent(conversation);
}, false);
},
// Update DOM on a Received Event
receivedEvent: function(id) {
Expand Down Expand Up @@ -149,6 +162,7 @@ var app = {
document.getElementById("display-carousel-btn").style.visibility = 'visible';
document.getElementById("display-article-btn").style.visibility = 'visible';
document.getElementById("display-survey-btn").style.visibility = 'visible';
document.getElementById("display-conversation-btn").style.visibility = 'visible';
document.getElementById("login-btn").style.visibility = 'hidden';
},

Expand All @@ -159,6 +173,7 @@ var app = {
document.getElementById("display-carousel-btn").style.visibility = 'hidden';
document.getElementById("display-article-btn").style.visibility = 'hidden';
document.getElementById("display-survey-btn").style.visibility = 'hidden';
document.getElementById("display-conversation-btn").style.visibility = 'hidden';
document.getElementById("login-btn").style.visibility = 'visible';
}
};
Expand Down
52 changes: 25 additions & 27 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
version: 2
version: 2.1

orbs:
android: circleci/[email protected]

setup_ruby: &setup_ruby
run:
name: Setup Ruby
command: sed -i '' 's/.*chruby ruby.*/chruby ruby-3.3.0/' ~/.bash_profile

jobs:
ios:
macos:
xcode: "13.4.1"
resource_class: macos.x86.medium.gen2
xcode: "15.4.0"
resource_class: macos.m1.large.gen1
shell: /bin/bash --login -eo pipefail
steps:
- <<: *setup_ruby
- checkout
- run:
name: Install node/npm
Expand All @@ -22,35 +31,28 @@ jobs:
command: cd Example && cordova plugin add ../intercom-plugin
- run:
name: Build
command: cd Example && cordova build ios --buildFlag="-UseModernBuildSystem=0"
command: cd Example && cordova build ios

android:
docker:
- image: circleci/android:api-30
executor:
name: android/android-machine
resource-class: large
tag: default
environment:
- JVM_OPTS: -Xmx3200m
GRADLE_OPTS: -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.daemon=false -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-XX:MaxMetaspaceSize=512m" -Dorg.gradle.workers.max=2
working_directory: ~/project/Example
steps:
- checkout
- run:
name: Accept all Android licenses
command: |
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses || if [ $? -ne '141' ]; then exit $?; fi;
- run:
name: Install node/npm
command: |
curl -O https://packages.cloud.google.com/apt/doc/apt-key.gpg && sudo apt-key add apt-key.gpg
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt install -y nodejs
- run:
name: Install gradle
command: sudo apt-get install gradle
- run:
name: Install Cordova
command: sudo npm install -g cordova@9.0.0
command: npm install -g cordova@12.0.0
- run:
name: Add Android platform
command: cd Example && cordova platform add android@10.0.0
command: cd Example && cordova platform add android@latest
- run:
name: Install intercom plugin
command: cd Example && cordova plugin add ../intercom-plugin
Expand All @@ -59,16 +61,12 @@ jobs:
command: cd Example && cordova build android --verbose -- --gradleArg=--stacktrace

publish:
docker:
- image: circleci/android:api-28
executor:
name: android/android-machine
resource-class: large
tag: default
steps:
- checkout
- run:
name: Install node/npm
command: |
curl -O https://packages.cloud.google.com/apt/doc/apt-key.gpg && sudo apt-key add apt-key.gpg
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt install -y nodejs
- run:
name: Publish to npm
command: |
Expand All @@ -77,7 +75,7 @@ jobs:
cd intercom-plugin && npm publish
workflows:
version: 2
version: 2.1
ios_and_android:
jobs:
- ios:
Expand Down
6 changes: 3 additions & 3 deletions intercom-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
"engines": [
{
"name": "cordova",
"version": ">=9.0.0"
"version": ">=12.0.0"
},
{
"name": "cordova-android",
"version": ">=10.0.0"
"version": ">=13.0.0"
},
{
"name": "cordova-ios",
"version": ">=6.2.0"
"version": "7.1.0"
}
],
"author": "Intercom",
Expand Down
14 changes: 10 additions & 4 deletions intercom-plugin/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="13.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="cordova-plugin-intercom" version="14.0.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 All @@ -8,9 +8,9 @@
<keywords>intercom,intercom-cordova</keywords>

<engines>
<engine name="cordova" version=">=9.0.0" />
<engine name="cordova" version=">=12.0.0" />
<engine name="cordova-android" version=">=10.0.0" />
<engine name="cordova-ios" version=">=6.2.0" />
<engine name="cordova-ios" version="7.1.0" />
</engines>

<js-module name="Intercom" src="www/intercom.js">
Expand All @@ -19,6 +19,12 @@
<clobbers target="plugin.intercom" />
</js-module>

<js-module name="IntercomContent" src="www/intercomContent.js">
<clobbers target="intercomContent" />
<clobbers target="cordova.plugins.intercomContent" />
<clobbers target="plugin.intercomContent" />
</js-module>


<platform name="ios">
<hook type="before_plugin_install" src="scripts/prepareCocoaPods.js" />
Expand Down Expand Up @@ -62,7 +68,7 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Intercom" spec="~> 13.0.0" />
<pod name="Intercom" spec="~> 17.1.1" />
</pods>
</podspec>
</platform>
Expand Down
28 changes: 20 additions & 8 deletions intercom-plugin/src/ios/IntercomBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,43 @@

@interface IntercomBridge : CDVPlugin

#pragma mark - User Login

- (void)loginUserWithUserAttributes:(CDVInvokedUrlCommand*)command;
- (void)loginUnidentifiedUser:(CDVInvokedUrlCommand*)command;
- (void)logout:(CDVInvokedUrlCommand*)command;

- (void)setUserHash:(CDVInvokedUrlCommand*)command;

- (void)updateUser:(CDVInvokedUrlCommand*)command;

#pragma mark - Events

- (void)logEvent:(CDVInvokedUrlCommand*)command;

- (void)unreadConversationCount:(CDVInvokedUrlCommand*)command;
#pragma mark - Present Intercom UI

- (void)present:(CDVInvokedUrlCommand*)command;
- (void)presentIntercomSpace:(CDVInvokedUrlCommand*)command;
- (void)presentContent:(CDVInvokedUrlCommand*)command;
- (void)presentMessageComposer:(CDVInvokedUrlCommand*)command;

#pragma mark - Help Center Data API

- (void)displayMessenger:(CDVInvokedUrlCommand*)command;
- (void)displayMessageComposer:(CDVInvokedUrlCommand*)command;
- (void)displayHelpCenter:(CDVInvokedUrlCommand*)command;
- (void)displayHelpCenterCollections:(CDVInvokedUrlCommand*)command;
- (void)fetchHelpCenterCollections:(CDVInvokedUrlCommand*)command;
- (void)fetchHelpCenterCollection:(CDVInvokedUrlCommand*)command;
- (void)searchHelpCenter:(CDVInvokedUrlCommand*)command;

#pragma mark - Intercom UI Visibility

- (void)setLauncherVisibility:(CDVInvokedUrlCommand*)command;
- (void)setBottomPadding:(CDVInvokedUrlCommand*)command;
- (void)setInAppMessageVisibility:(CDVInvokedUrlCommand*)command;
- (void)hideIntercom:(CDVInvokedUrlCommand*)command;

#pragma mark - Unread Conversation Count

- (void)registerForPush:(CDVInvokedUrlCommand*)command;
- (void)unreadConversationCount:(CDVInvokedUrlCommand*)command;

#pragma mark - Push Notifications

- (void)registerForPush:(CDVInvokedUrlCommand*)command;
@end
Loading

0 comments on commit 0455839

Please sign in to comment.