chabokpush_flutter

Creator: coderz1093

Last updated:

0 purchases

chabokpush_flutter Image
chabokpush_flutter Images

Languages

Categories

Add to Cart

Description:

chabokpush flutter

Chabok Push Client for Flutter #

Flutter wrapper for chabok library.
This client library supports Flutter to use chabok push library.
A Wrapper around native library to use chabok functionalities in Flutter environment.
Installation #
For installation refer to Flutter docs and platform specific parts (Android and iOS).
Release Note #
You can find release note here.
Support #
Please visit Issues.
Screenshot #

Getting Started - Android #

Add Google and Chabok plugins to build.gradle project level file.

buildscript {
repositories {
google()
jcenter()

maven {
url "https://plugins.gradle.org/m2/"
}
}

dependencies {
classpath "com.android.tools.build:gradle:3.4.2"

classpath "io.chabok.plugin:chabok-services:1.0.0"
classpath "com.google.gms:google-services:4.3.2"
}
}
copied to clipboard

Apply Google and Chabok plugins to build.gradle application level file.

dependencies {
// your project dependencies
}

apply plugin: 'io.chabok.plugin.chabok-services'
apply plugin: 'com.google.gms.google-services'
copied to clipboard

Initialize Chabok SDK in your MainApplication.java:

import com.adpdigital.push.AdpPushClient;
import com.adpdigital.push.config.Environment;

import io.flutter.app.FlutterApplication;

public class MainApplication extends FlutterApplication {
@Override
public void onCreate() {
super.onCreate();

AdpPushClient.configureEnvironment(Environment.SANDBOX); // or PRODUCTION
}
}
copied to clipboard
Getting started - iOS #

Ensure your iOS projects Pods are up-to-date:

$ cd ios
$ pod install --repo-update
copied to clipboard

Initialize Chabok SDK in your AppDelegate.m:

#import "AppDelegate.h"
#import <AdpPushClient/AdpPushClient.h>

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[PushClientManager.defaultManager configureEnvironment:Sandbox]; // or PRODUCTION

[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
copied to clipboard
Basic Usage #
In your main.dart:
Initialize #
For initializing the Chabok SDK in dart add bellow lines in import section:
import 'package:chabokpush_flutter/chabokpush.dart';
import 'package:chabokpush_flutter/ChabokEvent.dart';
import 'package:chabokpush_flutter/ChabokMessage.dart';
copied to clipboard
Login user #
To login user in the Chabok service use login method:
ChabokPush.shared.login('USER_ID');
copied to clipboard
Logout user #
To logout user in the Chabok service use logout method:
ChabokPush.shared.logout();
copied to clipboard
Set user attributes #
To set user attributes in the Chabok service use setUserAttributes method:
ChabokPush.shared.setUserAttributes(<String, dynamic> {
'firstName': 'Hossein',
'lastName': "Shooshtari",
'age': 27,
'birthday': new DateTime(1993),
'isVIP': true,
'friends': ['hussein', 'farbod']
});
copied to clipboard
Unset user attributes #
To unset user attributes in the Chabok service user unsetUserAttributes method:
ChabokPush.shared.unsetUserAttributes([
'isVIP'
]);
copied to clipboard
Getting message #
To get the Chabok message call setOnMessageCallback:
ChabokPush.shared.setOnMessageCallback((message) {
var msg = json.decode(message);
print('Got message = $msg');
});
copied to clipboard
Getting connection status #
To get connection state call setOnConnectionHandler:
ChabokPush.shared.setOnConnectionHandler((status) {
print('Connection status = $status');
});
copied to clipboard
Publish message #
For publishing a message use publish method:
ChabokPush.shared.publish(new ChabokMessage(
"RECEIVER_USER_ID",
"CHANNEL_NAME",
"YOUR MESSAGE")
);
copied to clipboard
Subscribe on channel #
To subscribe on a channel use subscribe method:
ChabokPush.shared.subscribe('CHANNEL_NAME')
.then((channel) {
print('successfully subscribed on channel: $channel');
}).catchError((error) {
print('failed to subscribe on channel with error: $error');
});
copied to clipboard
Unsubscribe from channel #
To unsubscribe from channel use unSubscribe method:
ChabokPush.shared.subscribe('CHANNEL_NAME')
.then((channel) {
print('successfully unsubscribed from channel: $channel');
}).catchError((error) {
print('failed to unsubscribe from channel with error: $error');
});
copied to clipboard
Track #
To track user interactions use track method :
ChabokPush.shared.track("AddToCart", <String, dynamic> {
'orderId': 'order_123',
'orderDate': new DateTime.now(),
'isBlackFriday': true,
'orderSize': 69
});
copied to clipboard
Add tag #
Adding tag to user use addTag method:
ChabokPush.shared.addTag("YOUR_TAG")
.then((response) {
print('successfully add tag');
}).catchError((error) {
print('failed to add tag with error: $error');
});
copied to clipboard
Remove tag #
Removing tag from user use removeTag method:
ChabokPush.shared.removeTag("YOUR_TAG")
.then((response) {
print('successfully remove tag');
}).catchError((error) {
print('failed to remove tag with error: $error');
});
copied to clipboard
Troubleshoot #
I see Errno::ENOENT - No such file or directory @ rb_sysopen - ./ios/Pods/Local Podspecs/chabokpush.podspec.json when I build an iOS app.
Clean your project, remove ios/Podfile and Xcode workspace file entirely. (make sure you have backups just in case)
flutter clean
rm -rf ios/Podfile ios/Podfile.lock pubspec.lock ios/Pods ios/Runner.xcworkspace
copied to clipboard
Revert to cocoapods 1.7.5 temporarily.
gem uninstall cocoapods
gem install cocoapods -v 1.7.5
copied to clipboard
Add the following line to the beginning of your iOS project's generated Podfile.
# Beginning of file
use_frameworks!

# The rest of the file contents
# ...
copied to clipboard
Install pods.
pod repo update
cd ios
pod install
cd ..
copied to clipboard
Retry your build.
Once your build is successful, you can update cocoapods back to its latest version. If the error reoccurs, you will have to revert back to 1.7.5 and retry the steps.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.