0.0.2 • Published 3 years ago

appotaminiappsdk v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

miniapp-sdk

📋 Yêu cầu

  • Ứng dụng ACheckin: https://acheckin.vn/
  • NodeJS & NPM (khuyên dùng) hoặc dự án Web có thể chạy độc lập không cần cài đặt lên server

🛠 Cài đặt

🚀 Tạo mới một dự án

Bạn có thể khởi tạo một ứng dụng mới hoàn toàn bằng công cụ ACheckin CLI do chúng tôi cung cấp.

Chú ý: ứng dụng được viết trên nền ReactJS.

  1. Cài đặt CLI

    npm install acheckin -global

  2. Tạo dự án mới

    acheckin init MyMiniApp [options]

    options
    • --template [js|ts|html] (Mặc định là js)
    • --id [your_bundle_id] (Mặc định acheckin.miniapp.myminiapp)
  3. Chúc mừng, bạn đã khởi tạo thành công!

    Nhập lệnh cd MyMiniApp && acheckin run và dùng ACheckin trên điện thoại quét mã QR được tạo trên Terminal.

📚 Thêm ACheckin SDK vào một dự án có sẵn

📖 API Reference

| API | Mô tả | Quyền truy cập | <<<<<<< HEAD | ----------- | ------ | ----------- | setHeaderTitle | Đặt tiêu đề của ứng dụng | none | | getAccessToken | Lấy token | none | | getUserInfo | Lấy thông tin người dùng | user_personal_email basic_info | done| getDeviceInfo | Lấy thông tin thiết bị | basic_device device_battery network_info device_ip| done | readQrBarCode | Đọc mã Qr hoặc Bar | device_camera | done| handleShakeDevice | Xử lý lắc thiết | device_shake | | showBottomBar | Hiển thị thanh công cụ dưới màn hình | none | | hideBottomBar | Ẩn thanh công ưới màn hình | none | | setLocalNotification | Cài đặt gửi thông báo tại local | device_notification | done | vibrateDevice | Sự kiện rung thiết bị | device_hardware | on process | setItem | Lưu giá trị vào bộ nhớ thiết bị | device_storage | on process | getItem | Lấy giá trị từ bộ nhớ thiết bị | device_storage | done| shareScreen | Chia sẻ màn hình tới các ứng dụng khác | basic_device | | isBioAvailable | Kiểm tra thiết bị có hỗ trợ sinh trắc học không | Đang cập nhật | | bioAuthenticate | Xác thực bằng sinh trắc học | Đang cập nhật | done| getCurrentLocation | Lấy vị trí hiện tại | device_location |

setHeaderTitle

  • Đặt tiêu đề của ứng dụng.
setHeadererTitle(string): Promise<any>;

getAccessToken

  • Lấy token.
getAccessToken(): Promise<string>;

getUserInfo

  • Lấy thông tin người dùng.
getUserPersonalInfo(Array<keyof UserPersonalInfo>): Promise<UserInfo>;
interface UserInfo {
	id: string;
	name: string;
	picture: string;
}

======= | ----------- | ------ | -----------| | getDeviceInfo | Lấy thông tin thiết bị | basic_device device_battery network_info device_ip| | readQrBarCode | Đọc mã Qr hoặc Bar | device_camera | | handleShakeDevice | Xử lý lắc thiết | device_shake | | setLocalNotification | Cài đặt gửi thông báo tại local | device_notification | | vibrateDevice | Sự kiện rung thiết bị | device_hardware | | setItem | Lưu giá trị vào bộ nhớ thiết bị | device_storage | | getItem | Lấy giá trị từ bộ nhớ thiết bị | device_storage | | removeItem | Xoá giá trị từ bộ nhớ theo key | device_storage | | clear | Xoá toàn bộ giá trị từ bộ nhớ | device_storage | | shareScreen | Chia sẻ màn hình tới các ứng dụng khác | basic_device | | isBioAvailable | Kiểm tra thiết bị có hỗ trợ sinh trắc học không | Đang cập nhật | | bioAuthenticate | Xác thực bằng sinh trắc học | Đang cập nhật | | getCurrentLocation | Lấy vị trí hiện tại | device_location | | playAudio | Play nhạc mp3 | none | | stopAudio | Stop nhạc mp3 | none | | selectDatetime | Chọn thời gian | none |

62886241e77944e7f2396cc650b6d11f09f7c7d3

getDeviceInfo

  • Lấy thông tin thiết bị.
getDeviceInfo(Array<keyof DeviceInfo>):Promise<DeviceInfo>;
interface DeviceInfo {
	device_id: string;
	device_name: string;
	device_platform: string;
	bundle_id: string;
	device_os_version: string;
	is_tablet: boolean;
	ip_address: string;
	battery_level: number;
	battery_changing: boolean;
	device_mac_address: string;
	device_manufacturer: string;
	device_brand: string;
	wifi_name: string;
	is_wifi: boolean;
	has_network: string;
	is_mobile_data: boolean;
}

readQrBarCode

  • Đọc QR hoặc bar code.
readBarCode():Promise<string>;

handleShakeDevice

  • Xử lý sự kiện lắc thiết bị.
addShakeEventListener(callback: () => void);

setLocalNotification

  • Cài đặt gửi thông báo tại local.
setLocalNotification(param: schedule): Promise<any>;
interface schedule {
	title: string;
	body: string;
	schedule?: number;
}

vibrateDevice

  • Sự kiện rung thiết bị.
vibrate(data:vibrate): Promise;
interface vibrate {
	type: 'nomal' | 'auto' | 'cancel'; 
 time:number ('milli seconds');
 delay:numer
}

setItem

  • Lưu giá trị vào bộ nhớ thiết bị.
setItem(key: string, value: string): Promise<boolean>;

getItem

  • Lấy giá trị từ bộ nhớ thiết bị.
getItem(key: string): Promise<string>;

removeItem

  • Xoá giá trị từ bộ nhớ thiết bị theo key.
removeItem(key: string): Promise<string>;

clear

  • Xoá toàn bộ giá trị từ bộ nhớ thiết bị.
clear(): Promise<string>;

bashareScreen

  • Chia sẻ màn hình tới các ứng dụng khác.
shareScreen(message: string): Promise<any>;

isBioAvailable

  • Kiểm tra thiết bị có hỗ trợ sinh trắc học không.
isSensorAvailable(): Promise<biometryType>;
- IOS: 
enum biometryType: 'Touch ID' | 'Face ID'
- ANDROID:
enum biometryType: 'Biometrics'

bioAuthenticate

  • Xác thực bằng sinh trắc học.
bioAuthenticate(param: params): Promise;
interface params {
	title: string; (android)
	subTitle: string; (android)
	description: string; (android & ios)
	cancelButton=string; (android)
}

getCurrentLocation

  • Lấy vị trí hiện tại
getCurrentLocation(): Promise<Location>;
interface Location {
  latitude: number;
  longitude: number;
}

playAudio

  • Play nhạc mp3
playAudio(audio: Audio): Promise<boolean>
interface Audio {
   url: string;
   background?: boolean;
   title?: string;
   artwork?: string;
}

stopAudio

  • Stop nhạc mp3
stopAudio(): Promise<boolean>

selectDatetime

  • Chọn thời gian
selectDatetime(date: Date): Promise<boolean>
interface Date {
   type: 'datetime' | 'time' | 'date';
   is_24_hour?: boolean;
}