Developer Docs | Kommunicate

Developer Docs | Kommunicate

  • Try For Free
  • Docs

›Flutter

Web

  • Installation
  • CMS Installation
  • Authentication
  • Conversation
  • Conversation Assignment
  • Customization
  • Localization
  • Logout
  • Troubleshooting

Android

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Migration
  • Troubleshooting

iOS

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Troubleshooting

React Native

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Logout

Flutter

  • Installation
  • Authentication
  • Customization
  • Conversation
  • Push Notification
  • Localization
  • Troubleshooting

Ionic/Cordova/Phonegap

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Resolving Errors

Ionic/Capacitor

  • Installation
  • Authentication
  • Push notification
  • Customization

Rich Messages

  • How To Use
  • Types of Rich Messages

Bots

  • Bot setup
  • Dialogflow Integration
  • Lex Integration
  • Kompose Bot Builder
  • IBM Watson Integration
  • Custom Bot Integration
  • Import Kompose Bot
  • Bot Samples

Integrations

  • Zapier
  • WhatsApp
  • WhatsApp 360Dialog
  • WhatsApp Twilio
  • WhatsApp Cloud API

Platform APIs

  • Authentication
  • Endpoints

Dashboard Features

  • Analytics
  • Conversations
  • Users
  • Bot Integration
  • Helpcenter
  • Settings

Configuration

  • Email Fallback
  • Webhooks
  • Access Token URL

Push Notification

Android

If you haven't already done the setup in Firebase and Kommunicate dashboard, follow the steps below:

For firebase setup and to get you server key follow this section.

Now go to Kommunicate dashboard Push Notification section, add the Server key obtained from firebase dashboard under GCM/FCM key and save.

Download the google-services.json file from the firebase dashboard and paste it under <YourApp>/android/app/ directory.

Download KmFirebaseMessagingService.java file and place it under <YourApp>/android/app/src/main/java/io/pushnotification/ directory.

Add KmFirebaseMessagingService.java entry inside the <application tag in <YourApp>/android/app/src/main/AndroidManifest.xml file as below (Refer here):

<service
     android:name="io.pushnotification.KmFirebaseMessagingService"
     android:exported="true"
     android:stopWithTask="false" />

Finally, follow these steps:

Goto <YourApp>/android/build.gradle

  1. Add the following under buildscript -> dependencies
classpath 'com.google.gms:google-services:3.0.0'
  1. Add the following at the bottom of the file:
apply plugin: 'com.google.gms.google-services'

After adding, it will look something like this:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    ...
    dependencies {
       classpath 'com.android.tools.build:gradle:2.2.1'
       classpath 'com.google.gms:google-services:3.1.1'
    }
}
...
apply plugin: 'com.google.gms.google-services'

iOS

Upload your APNS certificates for both development and distribution under Kommunicate dashboard Push Notification/iOS section. And update capabilities in Xcode as described here.

Open the project in XCode, Create new file with name KommunicateWrapper.swift in ios/Runner/. Copy the code for KommunicateWrapper.swift from this link and paste it inside your newly created file.

Open <YourApp>/ios/Runner/AppDelegate.swift file, if the file does not exists, create new one. Add the below code in the file:

import UIKit
import Flutter
import UserNotifications
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        GeneratedPluginRegistrant.register(with: self)
        UNUserNotificationCenter.current().delegate = self
        KommunicateWrapper.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        KommunicateWrapper.shared.userNotificationCenter(center, willPresent: notification, withCompletionHandler: { options in
            completionHandler(options)
        })
    }
    
    override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        KommunicateWrapper.shared.userNotificationCenter(center, didReceive: response, withCompletionHandler: {
            completionHandler()
        })
    }
    
    override func applicationWillTerminate(_ application: UIApplication) {
        KommunicateWrapper.shared.applicationWillTerminate(application: application)
    }
    
    override func applicationWillEnterForeground(_ application: UIApplication) {
        print("APP_ENTER_IN_FOREGROUND")
        UIApplication.shared.applicationIconBadgeNumber = 0
    }
    
    override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        print("DEVICE_TOKEN_DATA :: \(deviceToken.description)") // (SWIFT = 3) : TOKEN PARSING
        KommunicateWrapper.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
    }
}

Using flutter firebase messaging plugin

If you are using firebase_messaing plugin in your app for push notifications, follow the below steps to make Kommunicate notifications work with the Firebase plugin:

  1. Open KmPushNotificationService.java and extends it with FlutterFirebaseMessagingService instead of FirebaseMessagingService

  2. In the KmPushNotificationService.java file add the below import:

   import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingService;
  1. In AndroidManifest.xml file add or replace the below service inside <application tag:
   <service
        android:name="io.pushnotification.KmFirebaseMessagingService"
        tools:node="replace"
        android:exported="true"
        android:stopWithTask="false">
       <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
      </intent-filter>
   </service>
  1. Add the below tools entry (If not already added) inside the <manifest tag of AndroidManifest.xml file as below: xmlns:tools="http://schemas.android.com/tools"

    for example (2nd line in the below snippet):

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="io.kommunicate.kommunicate_flutter_plugin_example">
  1. Add the below entry in within the <application tag in your AndroidManifest.xml file:
   <service
        android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService"
        tools:node="remove"/>
← ConversationLocalization →
  • Android
  • iOS
  • Using flutter firebase messaging plugin

Ready to automate more than 80% of your customer support?

Try for Free
  • support@kommunicate.io
  • United States
    (+1) (310) 402-2374
  • India
    (+91) 974-057-0196
  • Docs
    • Web
    • Android
    • iOS
    • Ionic/Phonegap
    • React Native
    • Flutter
  • Product
    • Kompose Chatbot Builder
    • Live Chat
    • Integrations
    • Helpcenter
    • Dialogflow Integration
    • Features
    • Pricing and FAQs
    • Get Demo
  • Resources
    • Chatbots Templates
    • Blog
    • Kommunity
    • Support Metrics
    • Free SaaS Icons
    • ROI Calculator
    • Comparison
  • Company
    • About Us
    • Partner Program
    • Terms of Service
    • Privacy Policy
    • Jobs
    • SLA
    • DPA
  • Support
    • Knowledge Base
    • Docs
    • Stack Overflow
    • API Status
    • Contact Us
Software Advice Frontrunners for Live Chat Mar-22crozdesk badgeCapterra Shortlist for Live Chat Mar-22GetApp Category Leaders for Live Chat Mar-22GDPR compliant - GDPR Copy 12Created with Sketch.COMPLIANTG2 reviews badge
Copyright © 2023 Kommunicate.io