Skip to content

Commit

Permalink
chore: update readme, fix iOS bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Oct 13, 2022
1 parent 9a3436d commit 2656294
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

Use the native Freshchat SDK (iOS / Android) in Titanium

## Setup

### iOS

No setup required

### Android

Add the following contents to your [app]/platform/android/build.gradle
```gradle
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
```

## Example

See the [app.js](./example/app.js) for a full-featured example!
Expand Down
17 changes: 9 additions & 8 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ import Freshchat from 'ti.freshchat';

const APP_ID = 'YOUR_APP_ID';
const APP_KEY = 'YOUR_APP_KEY';
const APP_DOMAIN = null; // optional

// -------- Set your credentials here --------

const window = Ti.UI.createWindow({ layout: 'vertical' });
window.addEventListener('open', () => initializeSDK());

addButton('Sign in user');
addButton('Update user');
addButton('Reset user');
addButton('Track event');
addButton('Open conversations');
addButton('Sign in user', signInUser);
addButton('Update user', updateUser);
addButton('Reset user', signOutUser);
addButton('Track event', trackEvent);
addButton('Show conversations', showConversations);

window.open();

function initializeSDK() {
Freshchat.initialize({ appId: APP_ID, appKey: APP_KEY });
Freshchat.initialize({ appId: APP_ID, appKey: APP_KEY, domain: APP_DOMAIN });
}

function addButton(title, action) {
Expand All @@ -45,6 +46,6 @@ function trackEvent() {
Freshchat.trackEvent('test_event', { prop1: true, hello: 'tirocks' });
}

function openConversions() {
Freshchat.openConversions();
function showConversations() {
Freshchat.showConversations();
}
4 changes: 2 additions & 2 deletions ios/Classes/TiFreshchatModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class TiFreshchatModule: TiModule {
}

@objc(showConversations:)
func showConversations(args: [Any]) {
Freshchat.sharedInstance().showConversations(TiApp().controller.topPresentedController())
func showConversations(unused: [Any]?) {
Freshchat.sharedInstance().showConversations(TiApp.sharedApp().controller.topPresentedController())
}
}

Expand Down

0 comments on commit 2656294

Please sign in to comment.