Giter VIP home page Giter VIP logo

channel_talk_flutter's Introduction

channel_talk_flutter

Flutter wrapper for Channel Talk Android and iOS projects.(Unofficial)

Usage

import 'package:channel_talk_flutter/channel_talk_flutter.dart';

void main() async {
    await ChannelTalk.boot(
        pluginKey: 'pluginKey', // Required
        memberId: 'memberId',
        memberHash: 'memberHash',
        email: 'email',
        name: 'name',
        mobileNumber: 'mobileNumber',
        avatarUrl: 'avatarUrl',
        unsubscribeEmail: false,
        unsubscribeTexting: false,
        trackDefaultEvent: false,
        hidePopup: false,
        language: Language.korean,
        appearance: Appearance.dark,
    );

    ChannelTalk.setListener((event, arguments) {
      switch(event){
        case ChannelTalkEvent.onShowMessenger:
          print('ON_SHOW_MESSENGER');
          break;
        case ChannelTalkEvent.onHideMessenger:
          print('ON_HIDE_MESSENGER');
          break;
        case ChannelTalkEvent.onChatCreated:
          print('ON_CHAT_CREATED:\nchatId: $arguments');
          break;
        case ChannelTalkEvent.onBadgeChanged:
          print('ON_BADGE_CHANGED:\n$arguments');
          break;
        case ChannelTalkEvent.onFollowUpChanged:
          print('ON_FOLLOW_UP_CHANGED\ndata: $arguments');
          break;
        case ChannelTalkEvent.onUrlClicked:
          print('ON_URL_CLICKED\nurl: $arguments');
          break;
        case ChannelTalkEvent.onPopupDataReceived:
          print('ON_POPUP_DATA_RECEIVED\nevent: $arguments}');
          break;
        case ChannelTalkEvent.onPushNotificationClicked:
          print('ON_PUSH_NOTIFICATION_CLICKED\nevent: $arguments}');
        default:
          break;
      }
    });

    runApp(App());
}

class App extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return FlatButton(
            child: Text('Open Channel Talk'),
            onPressed: () async {
                await ChannelTalk.showMessenger();
            },
        );
    }
}

See Channel Talk Android and iOS package documentation for more information.

iOS

Update info.plist.

<key>NSCameraUsageDescription</key>
<string>Accessing to camera in order to provide better user experience</string>

<key>NSMicrophoneUsageDescription</key>
<string>Accessing to microphone to record voice for video</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Accessing to photo library in order to save photos</string>
 
<key>NSPhotoLibraryUsageDescription</key>
<string>Accessing to photo library in order to provide better user experience</string>

Add pod installation to ios/Podfile. (Because there is no latest ChannelIOSDK pod in Cocopod, can not add dependecy to plugin podspec properly.)

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  # Add below line
  pod 'ChannelIOSDK', podspec: 'https://mobile-static.channel.io/ios/11.7.3/xcframework.podspec'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Add ChannelTalk initializing code to [project]/ios/Runner/AppDelegate.swift

import ChannelIOFront
...

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        ...
        ChannelIO.initialize(application)
        ...
    }
...

Android

Push notifications in combination with FCM

This plugin works in combination with the firebase_messaging plugin to receive Push Notifications. To set this up:

    <service
        android:name="ai.deepnatural.channel_talk.PushInterceptService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

just above the closing </application> tag.

Web

Insert the following script within the tag of your HTML file(web/index.html):

<script>
  (function(){var w=window;if(w.ChannelIO){return w.console.error("ChannelIO script included twice.");}var ch=function(){ch.c(arguments);};ch.q=[];ch.c=function(args){ch.q.push(args);};w.ChannelIO=ch;function l(){if(w.ChannelIOInitialized){return;}w.ChannelIOInitialized=true;var s=document.createElement("script");s.type="text/javascript";s.async=true;s.src="https://cdn.channel.io/plugin/ch-plugin-web.js";var x=document.getElementsByTagName("script")[0];if(x.parentNode){x.parentNode.insertBefore(s,x);}}if(document.readyState==="complete"){l();}else{w.addEventListener("DOMContentLoaded",l);w.addEventListener("load",l);}})();
</script>

In case of Web platform, would better use bootForWeb API but we can also use boot API.

import 'package:channel_talk_flutter/channel_talk_flutter.dart';

void main() async {
    await ChannelTalk.bootForWeb(
        pluginKey: 'pluginKey', // Required
        memberId: 'memberId',
        memberHash: 'memberHash',
        email: 'email',
        name: 'name',
        mobileNumber: '0101231234',
        avatarUrl: 'avatarUrl',
        customLauncherSelector: 'customLauncherSelector',
        hideChannelButtonOnBoot: false,
        zIndex: 10000000,
        trackDefaultEvent: false,
        trackUtmSource: false,
        unsubscribeEmail: false,
        unsubscribeTexting: false,
        hidePopup: false,
        appearance: Appearance.light,
        language: Language.japanese,
    );
...
}

Supported API

API API Description Parameter Type Parameter Description Support platforms
setListener Set the delegate allows the reception of event callbacks from the SDK. delegate* ChannelTalkDelegate Support onShowMessenger/onHideMessenger/onChatCreated/onBadgeChanged/onFollowUpChanged/onUrlClicked/onPopupDataReceived Mobile
removeListener Remove the delegate allows the reception of event callbacks from the SDK.q Mobile
boot Load the information necessary to use the SDK. pluginKey* String Plugin key of Channel. Mobile, Web
memberId String? An identifier to distinguish each member user.
memberHash String? A HMAC-SHA256 value of memberId.
email String? An email of a user.
name String? A name of a user.
mobileNumber String? A mobile number of a user.
avatarUrl String? An avatar URL of a user.
language Language? A user’s language. It is valid when creating a new user. The language of the user that already exists will not change.
unsubscribeEmail bool? Sets whether to receive marketing messages via email.
unsubscribeTexting bool? Sets whether to receive marketing messages via texting (SMS, LMS)
trackDefaultEvent bool? Sets whether to track the default event, such as PageView.
hidePopup bool? Sets whether to hide popups such as marketing popup and in-app notifications.
appearance Appearance? Sets the appearance of SDK.
bootForWeb Load the information necessary to use the SDK. pluginKey* String Plugin key of Channel. Web
memberId String? An identifier to distinguish each member user.
memberHash String? A HMAC-SHA256 value of memberId.
email String? An email of a user.
name String? A name of a user.
mobileNumber String? A mobile number of a user.
avatarUrl String? An avatar URL of a user.
language Language? A user’s language. It is valid when creating a new user. The language of the user that already exists will not change.
unsubscribeEmail bool? Sets whether to receive marketing messages via email.
unsubscribeTexting bool? Sets whether to receive marketing messages via texting (SMS, LMS)
trackDefaultEvent bool? Sets whether to track the default event, such as PageView.
hidePopup bool? Sets whether to hide popups such as marketing popup and in-app notifications.
appearance Appearance? Sets the appearance of SDK.
customLauncherSelector String? The CSS Selector to select a custom launcher. Use this option to customize the default chat button.
hideChannelButtonOnBoot bool? Determines whether to hide the default chat button on boot. The default value is false.
zIndex int? Sets the z-index for SDK elements, such as the chat button, messenger, and marketing pop-ups. The default value is 10000000.
trackUtmSource bool? Determines whether to track the UTM source and referrer. The default value is true.
sleep Disables all features except for receiving system push notifications and using the Track. Mobile
shutdown Disconnects the SDK from the channel. Mobile, Web
showChannelButton Displays the Channel button on the global screen. Mobile, Web
hideChannelButton Hides the Channel button on the global screen. Mobile, Web
showMessenger Displays the messenger. Mobile, Web
hideMessenger Hides the messenger. Mobile, Web
openChat Opens User chat. chatId String? This is the chat ID. If the chatId is invalid or nil, a new user chat is opened. Mobile, Web
message String? This is the pre-filled message in the message input field when opening a new chat. It is valid when chatId is nil.
track Tracks the user's events. eventName* String This is the name of the event to track, with a maximum length of 30 characters. Mobile, Web
properties Map? This is additional information about the event.
updateUser TraModifies user information. name String? A name of a user. Mobile, Web
email String? An email of a user.
mobileNumber String? A mobile number of a user.
avatarUrl String? An avatar URL of a user.
language Language? A user’s language. It is valid when creating a new user. The language of the user that already exists will not change.
unsubscribeEmail bool? Sets whether to receive marketing messages via email.
unsubscribeTexting bool? Sets whether to receive marketing messages via texting (SMS, LMS)
tags List[String]? A tag list of the user.
customAttributes Map < String, dynamic >? A user's CustomAttributes
initPushToken Informs ChannelTalk about updates to the device token. deviceToken* String This is additional information about the event. Mobile
isChannelPushNotification It checks if the push data should be processed by the SDK. content* Map This is the `userInfo object received through push notifications. Mobile
receivePushNotification Notifies Channel Talk that the user has received a push notification. content* Map This is the `userInfo object received through push notifications. Mobile
storePushNotification Stores push information on the device. content* Map This is the `userInfo object received through push notifications. Mobile
hasStoredPushNotification Check for any saved push notifications from the Channel. Mobile
openStoredPushNotification Opens a user chat using the stored push information on the device through �storePushNotification. Mobile
isBooted Verify that the SDK is in a Boot state. Mobile
setDebugMode Sets the debug mode. flag* String debug mode Mobile
setPage Sets the name of the screen when the track is called. page* String This is the screen name when track is called. Mobile, Web
resetPage Resets the name of the screen when track is called. Mobile, Web
addTags Adds tags to the user. tags* List[String] • The maximum number of tags that can be added is 10.
• Tags are stored in lowercase.
• Any tags that have already been added will be ignored.
• nil, empty strings, or lists containing them are not allowed.
Mobile, Web
removeTags Removes tags from the user, ignoring any tags that do not exist. tags* List[String] These are the tags to be removed. Null, empty strings, or lists containing them are not allowed. Mobile, Web
openSupportBot Opens User chat to run a specific Support bot. supportBotId* String? This is the support bot's ID. If supportBotId is invalid or nil, the chat room is closed. Mobile, Web
message String? This message will be displayed in the input field after completing the support bot operation.
setAppearance Configures the SDK's theme. appearance* Appearance If specified as .light or .dark, it locks the theme to the respective mode. If specified as .system, it follows the device's system theme. Mobile, Web

channel_talk_flutter's People

Contributors

2no avatar bc-yoshiyuki-kawano avatar i2gor87 avatar turlvo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

channel_talk_flutter's Issues

v2.3.1 안드로이드 gradle 빌드 에러

안녕하세요 이전까지 2.1.1 버전으로 잘 사용하고 있었습니다. 감사합니다.
2.3.1 버전으로 업데이트를 하니 iOS에서는 문제가 없는데 안드로이드는 빌드시 아래와같은 에러가 발생하네요

/dev/flutter/.pub-cache/hosted/pub.dartlang.org/channel_talk_flutter-2.3.1/android/build.gradle' line: 32

* What went wrong:
A problem occurred evaluating project ':channel_talk_flutter'.
> Could not set unknown property 'includeCompileClasspath' for AnnotationProcessorOptions_Decorated{classNames=[], arguments={}, compilerArgumentProviders=[]} of type com.android.build.gradle.internal.dsl.AnnotationProcessorOptions.

build.gradle 파일의 아래 부분이 추가되어서 발생하는 문제인걸로 보이는데요 혹시 추가하신 이유가 있으실까요?
해당 부분을 임시로 삭제하고 빌드해보니 정상작동해서요

javaCompileOptions {
    annotationProcessorOptions {
        includeCompileClasspath = false
    }
}

Web 미지원

안녕하세요.
저희는 Flutter로 모바일용 Web 도 대응하고 있는데
현재 해당 라이브러리로 Web까지는 지원이 안되는 듯 합니다.

ChannelTalk.boot: MissingPluginException(No implementation found for method boot on channel channel_talk)

Android profile or release build issue

안녕하세요. 안드로이드 profile or release 를 빌드하게 되면 아래와 같은 이슈를 내며 빌드를 실패 합니다. 현재 채널톡이 들어간 오류가 발생하는데 채널톡 라이브러리랑 연관이 있을까요?

Execution failed for task ':channel_talk_flutter:verifyProfileResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:3: AAPT: error: resource android:color/system_neutral1_1000 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:4: AAPT: error: resource android:color/system_neutral1_900 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:5: AAPT: error: resource android:color/system_neutral1_0 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:6: AAPT: error: resource android:color/system_neutral1_800 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:7: AAPT: error: resource android:color/system_neutral1_700 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:8: AAPT: error: resource android:color/system_neutral1_600 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:9: AAPT: error: resource android:color/system_neutral1_500 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:10: AAPT: error: resource android:color/system_neutral1_400 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:11: AAPT: error: resource android:color/system_neutral1_300 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:12: AAPT: error: resource android:color/system_neutral1_200 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:13: AAPT: error: resource android:color/system_neutral1_100 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:14: AAPT: error: resource android:color/system_neutral1_50 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:15: AAPT: error: resource android:color/system_neutral1_10 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:16: AAPT: error: resource android:color/system_neutral2_1000 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:17: AAPT: error: resource android:color/system_neutral2_900 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:18: AAPT: error: resource android:color/system_neutral2_0 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:19: AAPT: error: resource android:color/system_neutral2_800 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:20: AAPT: error: resource android:color/system_neutral2_700 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:21: AAPT: error: resource android:color/system_neutral2_600 not found.

     ERROR:/Users/junguk/dev/project/flutter-pawdly-partner/build/channel_talk_flutter/intermediates/merged_res/profile/values-v31/values-v31.xml:22: AAPT: error: resource android:color/system_neutral2_500 not found.

Error on user update

if let _ = user, error != nil {

This code won't proceed if user not nil and error not nil as well. Instead, it will fail without any error message.
#3 aims to fix this behaviour by changing this code as follows:

if let _ = user, user != nil {

채널톡 알림 설정

안녕하세요.

혹시 앱이 background 상태일때 채널톡이 왔을 경우 푸시를 보내는 방법이 있을까요??
fcm과 연동이 되는지 궁금합니다!

MainActivity has leaked

Activity io.everybike.bike.MainActivity has leaked IntentReceiver io.channel.libs.youtube.player.utils.NetworkListener@212c43a that was originally registered here. Are you missing a call to unregisterReceiver()

백버튼으로 화면 탈출시 위와같은 warning 메세지가 확인되어 리포트합니다.

flutter_inappwebview를 사용중입니다. 2.x 버전과 3.0 버전에서의 차이로 인해 3.0을 사용할 수 없는데 2.x 버전이 추가로 업데이트 될 여지는 있을까요?

현재 인앱웹뷰를 통해 서비스를 진행하고 있습니다.
flutter_inappwebview 6.0.0 버전에서 사용되는 js 버전이 0.6.4 인 상태인데
최근 업데이트 된 channel_talk_flutter 3.0.0 버전에서는 js 버전이 0.7.1 입니다.
뭐 결국 flutter_inappwebview 쪽에서 업데이트를 해줘야겠으나 현재 2.6.2 버전 이후로는 의존성 때문에 더 올릴 수 없는 상태라서요.
그런 상태이기때문에 현재 운영중인 2.x 버전이 추가로 업데이트 진행될 여지가 있으실지 질문드려봅니다.

iOS 채널톡 SDK 11.6.0 이상 실행 안 됨 이슈

안녕하세요
iOS 버전 채널톡 SDK 11.6.0 버전 이후부터는 showMessenger()를 해도 아무런 반응이 없습니다.

아래 코드처럼 pod의 버전을 11.5.0으로 하면 정상 작동하여 현재는 해당 버전으로 고정하여 사용 중입니다.

pod 'ChannelIOSDK', podspec: 'https://mobile-static.channel.io/ios/11.5.0/xcframework.podspec'

최근에 버전이 업데이트된 것을 확인하여 이슈 작성합니다.
감사합니다.

iOS Push 가 수신되지 않습니다

아직 프로젝트 설정 단계중 이긴 한데요,

FCM 설정을 완료 해도 iOS 단말기에서 푸시가 수신되지 않는 현상이 있습니다.

혹시 다른 설정을 해줘야 할게 있을까요?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.