当前位置: 首页 > 软件库 > 手机/移动开发 > >

nativescript-live-engage

授权协议 View license
开发语言 JavaScript TypeScript
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 蒲深
操作系统 iOS
开源组织
适用人群 未知
 软件概览

NativeScript plugin for LivePerson LiveEngage

This is a plugin to show the conversation from a LiveEngage chat, using the LP-Messaging SDK (Android v3.6.0, iOS v3.6.0).

Requirements

Installation

Run the following command from the root of your project:

npm install nativescript-live-engage

Setup

At the launch of your app call initializeChat with your credentials (our example main.ts):

LiveEngage.getInstance().initializeChat('12345678', 'com.example.myapp');

Android

  1. Set the minSdkVersion to at least 19, in your AndroidManifest.xml and app.gradle.

  2. Include the following dependencies in the include.gradle file of your app:

    compile "com.android.support:appcompat-v7:24.2.1"
      compile "com.android.support:design:24.2.1"
      compile "com.android.support:percent:24.2.1"
      compile 'com.google.android.gms:play-services-maps:9.8.0'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
    
      compile 'com.squareup.picasso:picasso:2.5.2'
      compile 'com.neovisionaries:nv-websocket-client:1.31'
      compile 'com.squareup.okhttp3:okhttp:3.6.0'

iOS

You need to enable keychain sharing, to do this we need a custom entitlements file with a keychain-access-groups key.

Add nativescript-custom-entitlements to your devDependencies and create a new entitlements file like our example app.entitlements.

Chatting

To open the chat window call showChat:

LiveEngage.getInstance().showChat();

Optional functions

Setting customer information

Add the first name, last name, nick name, avatar url or phone number of a user.

const chatProfile: ChatProfile = {
          firstName: 'Jane',
          lastName: 'Doe',
          nickName: 'JD',
          phone: '0132100000',
          avatarUrl: ''
      };
LiveEngage.getInstance().setUserProfileValues(chatProfile);

oAuth

Add a JWT for oAuth support when starting a conversation. Make sure you configure the Live Person data source to support the oAuth 2 authentication in terms of Live person public keys, Signing identities and possible (custom) claims definitions. Make sure to call this method before you start the conversation.

LiveEngage.getInstance().setAuthenticationCode('<JWT encoded token string>');

Hiding chat

When you want to hide the chat window programmatically call closeChat().

LiveEngage.getInstance().closeChat();

Logging Out

When you want to remove all user data and unregister for push notifications call killChat().

LiveEngage.getInstance().killChat()
            .then(() => {
                console.log('killChat success');
            }).catch((error: any) => {
                console.log('killChat error', error);
        });

Push Notifications

To recieve push notifications when the agent sends a new message you need to send the push token to LivePerson.When you have a push token (FCM for Android and APNS for iOS) you can send it to LivePerson using registerPushToken

LiveEngage.getInstance().registerPushToken('your-token');

Parsing message on Android

To parse the push notification message on android in onMessageReceived() in your FirebaseMessagingService, use parsePushMessage().This will return a PushMessageParser object which has the method getMessage() to return the title of the push message.

try {
    const message = LiveEngage.getInstance().parsePushMessage(data);
    console.log(message.getMessage());
} catch (e) {
    console.error("Failed to parse message:", e);
}

Getting unread message count

To get the total amount of unread messages, use getUnreadMessagesCount().This will only work when push notifications are enabled.

LiveEngage.getInstance().getUnreadMessagesCount((count: number) => {
    console.log('Unread messages:', count);
}, (error: any) => {
    console.log('Failed to get count: ', error);
});

Close window callback on iOS

To get notified when the conversation was dismissed, you can provide a callback when opening the chat on iOS:

LiveEngage.getInstance().showChat(() => {
    console.log('Chat window was closed');
});

Development setup

For easier development and debugging purposes continue with the following steps:

Open a command prompt/terminal, navigate to src folder and run npm run demo.ios or npm run demo.android to run the demo.

Now go and make a change to your plugin. It will be automatically applied to the demo project.

Clean plugin and demo files

Sometimes you may need to wipe away all generated folders to reinstall them fresh.Run npm run clean to wipe those clean then you can can run plugin.prepare to install fresh dependencies.

Sometimes you just need to wipe out the demo's platforms, node_modules and hooks directory only.Run npm run demo.reset to delete those.

 相关资料
  • Live Reload指定文件系统中的更改。 BrowserSync用于监视CSS目录中的所有HTML和CSS文件,并在文件更改时对所有浏览器中的页面执行实时重新加载。 BrowserSync通过跨多个设备同步URL,交互和代码更改,使工作流程更快。 安装BrowserSync插件 BrowserSync插件提供跨浏览器的CSS注入,可以使用以下命令进行安装。 npm install browse

  • 本文向大家介绍emacs-live,包括了emacs-live的使用技巧和注意事项,需要的朋友参考一下 示例 emacs-live是另一种流行的emacs入门套件,另外还重点关注使用泛音进行的现场音乐编码。 您可以通过两种方式安装它: 在* nix(例如Linux,OSX等)系统上,在命令行上运行以下命令: bash <(curl -fksSL https://raw.github.com/ove

  • Live example In this example we highlight new features in our latest release, including the image caption option, media embeds and code snippets. For more information on the latest updates to TinyMCE,

  • 直播组件 属性 类型 默认值 必填 说明 src string 否 音视频地址。 mode string live 否 模式 autoplay boolean false 否 自动播放 muted boolean false 否 是否静音 orientation string vertical 否 画面方向 object-fit string contain 否 填充模式,可选值有 contain

  • Live USB 是USB隨身碟或USB硬碟,裡面含有完整的作業系統,可以被用來開機(booting)。Live USB很像live CD, 但基本上有能力更改設定,而且可以把軟體安裝回USB裝置上。像live CD一樣,live USB可以使用在嵌入式系統系統管理,資料還原(data recovery),或是不需要把作業系統安裝到主機硬碟(local hard disk drive)裡的測試。許

  • Clonezilla Live是基于Debian的自启动运行光盘,它包含了一份类似Norton Ghost那样的分区/硬盘克隆软件Clonezilla。它保存并恢复硬盘上那些使用了的数据块。使用Clonezilla,用户可以在大约10分钟内 将5 GB的系统克隆到40份客户机上。