one_target_mobile_sdk 0.0.19 copy "one_target_mobile_sdk: ^0.0.19" to clipboard
one_target_mobile_sdk: ^0.0.19 copied to clipboard

G1 tracking's plugin

HƯỚNG DẪN SỬ DỤNG SDK ONETARGET FLUTTER

Link: https://pub.dev/packages/one_target_mobile_sdk

Import:

~Yaml: one_target_mobile_sdk: ^x.y.z (x.y.z là version)

~iOS: no

~Android:

Thêm vào gradle (level project):

allprojects {  
  repositories {  
  google()  
  mavenCentral()  
  maven { url 'https://jitpack.io' }  
  }  
}

Android manifest: thêm tag tools:replace="android:label" vào thẻ application.

Cách dùng:

1/ Khởi tạo các thông tin trước khi tracking:

void main() async {  
  WidgetsFlutterBinding.ensureInitialized();  
  _setupTracking();  
  runApp(const MyApp());  
}  
void _setupTracking() {  
  Constant.setEnv(Constant.ENV_DEV);  
  G1SDK  
      .setupSDK(  
  Constant.getEnv(),  
  Constant.getWorkSpaceId(),  
  isShowLog: false,  
  isEnableIAM: true,  
  )  
  .then((isSetupSuccess) {  
  Utils.log("_setupTracking isSetupSuccess $isSetupSuccess");  
  });  
}

2/ Tiến hành tracking bằng phương thức:

void _trackEvent() {  
  var platform = "";  
 if (Platform.isAndroid) {  
  platform = "Android";  
  } else if (Platform.isIOS) {  
  platform = "iOS";  
  }  
  var profile = <Map>[];  
  // profile.add({  
 //   "name": "Loitp Flutter", //   "email": "loitp@galaxy.one", // });  G1SDK.trackEvent(  
  Constant.getWorkSpaceId(),  
  {  
  "screen": "BookingSuccessScreen",  
  "phone": "123123123",  
  },  
  profile,  
  "purchase",  
  DateTime.now().millisecondsSinceEpoch,  
  {  
  "platform": platform,  
  "ecommerce.currency": "VND",  
  "ecommerce.transaction_id": "33AJV3",  
  "ecommerce.value": "2899800",  
  "ecommerce.items.0.item_id": "VJ197",  
  "ecommerce.items.0.item_name": "Flight:SGN:HAN",  
  "ecommerce.items.0.item_category": "FareOption",  
  "ecommerce.items.0.item_variant": "Deluxe",  
  "ecommerce.items.0.flight_time": "05:15-07:25",  
  "ecommerce.items.0.flight_date": "2020-11-19",  
  "ecommerce.items.0.flight_from": "SGN",  
  "ecommerce.items.0.flight_to": "HAN",  
  "ecommerce.items.0.item_list_id": "Outbound:HAN:SGN",  
  "ecommerce.items.0.index": "1",  
  "ecommerce.items.0.quantity": "1",  
  "ecommerce.items.0.price": "899000",  
  "ecommerce.items.1.item_id": "VJ120",  
  "ecommerce.items.1.item_name": "Flight:HAN:SGN",  
  "ecommerce.items.1.item_category": "FareOption",  
  "ecommerce.items.1.item_variant": "SkyBoss",  
  "ecommerce.items.1.flight_time": "20:50-23:45",  
  "ecommerce.items.1.flight_date": "2020-11-27",  
  "ecommerce.items.1.flight_from": "HAN",  
  "ecommerce.items.1.flight_to": "SGN",  
  "ecommerce.items.1.item_list_id": "Outbound:HAN:SGN",  
  "ecommerce.items.1.index": "2",  
  "ecommerce.items.1.quantity": "1",  
  "ecommerce.items.1.price": "2000800",  
  // "ecommerce.items.2.item_id": "VJ120",  
 // "ecommerce.items.2.item_name": "Flight:HAN:SGN", // "ecommerce.items.2.item_category": "FareOption", // "ecommerce.items.2.item_variant": "SkyBoss", // "ecommerce.items.2.flight_time": "20:50-23:45", // "ecommerce.items.2.flight_date": "2020-11-27", // "ecommerce.items.2.flight_from": "HAN", // "ecommerce.items.2.flight_to": "SGN", // "ecommerce.items.2.item_list_id": "Outbound:HAN:SGN", // "ecommerce.items.2.index": "2", // "ecommerce.items.2.quantity": "1", // "ecommerce.items.2.price": "2000800"  },  
  onResponse: (value) {  
  Utils.log(">>>onResponse $value");  
  },  
  onFailure: (value) {  
  Utils.log(">>>onFailure $value");  
  },  
  );  
}

HOW TO PUBLISH TO PUBDEV:

Dưới đây là hướng dẫn cho maintainer SDK flutter cách publish sdk lên pubdev. Các config đều đã được embeded, bây giờ chỉ cần thực hiện các step sau: Kiểm tra xem sdk flutter có lỗi hay warning gì trước khi upload lên pubdev hay không.

dart pub publish --dry-run
or
flutter packages pub publish --dry-run

Sau đó dùng lệnh này để upload toàn bộ package lên pubdev. Lưu ý nhớ nâng version trong yaml và update lại file CHANGELOG trước.

dart pub publish
or
flutter packages pub publish

Cách build APK:

cd example
flutter build apk

Output sẽ ở path: /Users/loitp/StudioProjects/g1/onetarget-flutter/onetarget-flutter/example/build/app/outputs

Tham khảo:

Add native lib iOS xcframework https://stackoverflow.com/questions/69214595/how-to-manually-add-a-xcframework-to-a-flutter-ios-plugin

Add native lib Android jitpack https://gitlab.com/g1-data/onetarget-android

loitp@galaxy.one
Teams: Tran Phu Loi
Phone: 0766040293