亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

MobPush for Flutter集成準(zhǔn)備

 更新時(shí)間:2022年11月27日 09:41:23   作者:MobTech開(kāi)發(fā)者  
這篇文章主要為大家介紹了MobPush for Flutter集成準(zhǔn)備實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

集成準(zhǔn)備

這是一個(gè)基于 MobPush 功能的擴(kuò)展的 Flutter 插件。使用此插件能夠幫助您在使用 Flutter 開(kāi)發(fā)應(yīng)用時(shí),快速地實(shí)現(xiàn)推送功能。

在pubspec.yaml文件中加入下面依賴

dependencies:
  mobcommonlib:
  mobpush_plugin:

然后執(zhí)行:flutter packages get 導(dǎo)入package 在你的dart工程文件中,導(dǎo)入下面頭文件,開(kāi)始使用

import 'package:mobcommonlib/mobcommonlib.dart';
import 'package:mobpush_plugin/mobpush_plugin.dart';

iOS

平臺(tái)配置參考 iOS集成文檔

實(shí)現(xiàn)文檔中 Xcode配置:配置AppKey和AppSecret

Android

導(dǎo)入 MobPush 相關(guān)依賴

在項(xiàng)目根目錄的build.gradle中添加以下代碼:

buildscript {
    repositories {
        // 配置Mob Maven庫(kù)
        maven {
           url "https://mvn.mob.com/android"
        }
      // 配置HMS Core SDK的Maven倉(cāng)地址。(集成華為廠商需要添加)
        maven {
           url 'https://developer.huawei.com/repo/'}
        }
        ...
    }
    dependencies {
        ...
        // 集成MobPush
        classpath "com.mob.sdk:MobSDK:2018.0319.1724"
    }
}

在 /android/app/build.gradle 中添加以下代碼:

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// 導(dǎo)入MobSDK
apply plugin: 'com.mob.sdk'

平臺(tái)相關(guān)集成 在項(xiàng)目的/android/app/build.gradle中添加:

MobSDK {
    appKey "您的MobTech平臺(tái)appKey"
    appSecret "您的MobTech平臺(tái)appSecret"
    //配置MobPush
    MobPush {
        //配置廠商推送(可選配置,不需要廠商推送可不配置,需要哪些廠商推送只需配置哪些廠商配置即可)
        devInfo {
            //配置小米廠商推送
            XIAOMI {
                appId "您的小米平臺(tái)appId"
                appKey "您的小米平臺(tái)appKey"
            }
            //配置華為廠商推送
            HUAWEI {
                appId "您的華為平臺(tái)appId"
            }
            //配置魅族廠商推送
            MEIZU {
                appId "您的魅族平臺(tái)appId"
                appKey "您的魅族平臺(tái)appKey"
            }
            //配置FCM廠商推送
            FCM {
                //設(shè)置默認(rèn)推送通知顯示圖標(biāo)
                iconRes "@mipmap/default_ic_launcher"
            }
            //配置OPPO廠商推送
            OPPO {
                appKey "您的OPPO平臺(tái)appKey"
                appSecret "您的OPPO平臺(tái)appSecret"
            }
            //配置VIVO廠商推送
            VIVO {
                appId "您的VIVO平臺(tái)appId"
                appKey "您的VIVO平臺(tái)appKey"
            }
        }
    }
}

添加代碼

在MainActivity的onCreate中添加以下代碼:

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }

SDK API

回傳用戶隱私授權(quán)結(jié)果 (submitPrivacyGrantResult)

/**
 * 回傳用戶隱私授權(quán)結(jié)果
 * @param status     用戶是否同意隱私協(xié)議
 * @param result     默認(rèn)傳null
 */  
Mobcommonlib.submitPolicyGrantResult(bool status, Function(bool)? result)

例:

Mobcommonlib.submitPolicyGrantResult(true, null);

設(shè)置遠(yuǎn)程推送環(huán)境

向用戶授權(quán)(setCustomNotification僅 iOS)

setCustomNotification
if (Platform.isIOS) {
      MobpushPlugin.setCustomNotification();
}

設(shè)置遠(yuǎn)程推送環(huán)境 (setAPNsForProduction僅 iOS)

setAPNsForProduction
if (Platform.isIOS) {
     // 開(kāi)發(fā)環(huán)境 false, 線上環(huán)境 true
      MobpushPlugin.setAPNsForProduction(false)
}

添加推送回調(diào)監(jiān)聽(tīng)(addPushReceiver 接收自定義透?jìng)飨⒒卣{(diào)、接收通知消息回調(diào)、接收點(diǎn)擊通知消息回調(diào)、接收別名或標(biāo)簽操作回調(diào))

addPushReceiver
MobpushPlugin.addPushReceiver(_onEvent, _onError);
void _onEvent(Object event) {
}
void _onError(Object event) {
}

停止推送(stopPush)

stopPush
MobpushPlugin.stopPush();

重新打開(kāi)推送服務(wù)(restartPush)

restartPush
MobpushPlugin.restartPush();

是否已停止接收推送(isPushStopped)

isPushStopped
MobpushPlugin.isPushStopped();

設(shè)置別名(setAlias)

setAlias
MobpushPlugin.setAlias("別名").then((Map<String, dynamic> aliasMap){
    String res = aliasMap['res'];
    String error = aliasMap['error'];
    String errorCode = aliasMap['errorCode'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> setAlias -> res: $res error: $error");
});

獲取別名(getAlias)

getAlias
MobpushPlugin.getAlias().then((Map<String, dynamic> aliasMap){
    String res = aliasMap['res'];
    String error = aliasMap['error'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> getAlias -> res: $res error: $error");
});

刪除別名(deleteAlias)

deleteAlias
MobpushPlugin.deleteAlias().then((Map<String, dynamic> aliasMap){
    String res = aliasMap['res'];
    String error = aliasMap['error'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> deleteAlias -> res: $res error: $error");
});

添加標(biāo)簽(addTags)

addTags
List tags = new List();
tags.add("tag1");
tags.add("tag2");
MobpushPlugin.addTags(tags).then((Map<String, dynamic> tagsMap){
    String res = tagsMap['res'];
    String error = tagsMap['error'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> addTags -> res: $res error: $error");
});

獲取標(biāo)簽(getTags)

getTags
MobpushPlugin.getTags().then((Map<String, dynamic> tagsMap) {
          List<String> resList;
          if (tagsMap['res'] == null) {
            resList = [];
          } else {
            resList = tagsMap['res'].toList();
          }
          String error = tagsMap['error'];
          print(
              ">>>>>>>>>>>>>>>>>>>>>>>>>>> getTags -> res: $resList error: $error");
        });

刪除標(biāo)簽(deleteTags)

deleteTags
List tags = new List();
tags.add("tag1");
tags.add("tag2");
MobpushPlugin.deleteTags(tags).then((Map<String, dynamic> tagsMap){
    String res = tagsMap['res'];
    String error = tagsMap['error'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> deleteTags -> res: $res error: $error");
});

清空標(biāo)簽(cleanTags)

cleanTags
MobpushPlugin.cleanTags().then((Map<String, dynamic> tagsMap){
    String res = tagsMap['res'];
    String error = tagsMap['error'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> cleanTags -> res: $res error: $error");
});

發(fā)送本地通知(addLocalNotification)

addLocalNotification
MobpushPlugin.addLocalNotification();

綁定手機(jī)號(hào)(bindPhoneNum)

bindPhoneNum
MobpushPlugin.bindPhoneNum("110");

測(cè)試模擬推送,用于測(cè)試(send)

send
/**
    * 測(cè)試模擬推送,用于測(cè)試
    * type:模擬消息類型,1、通知測(cè)試;2、內(nèi)推測(cè)試;3、定時(shí)
    * content:模擬發(fā)送內(nèi)容,500字節(jié)以內(nèi),UTF-8
    * space:僅對(duì)定時(shí)消息有效,單位分鐘,默認(rèn)1分鐘
    * extras: 附加數(shù)據(jù),json字符串
    */
MobpushPlugin.send(int type, String content, int space, String extras).then((Map<String, dynamic> sendMap){
    String res = sendMap['res'];
    String error = sendMap['error'];
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>> send -> res: $res error: $error");
});

設(shè)置點(diǎn)擊通知是否跳轉(zhuǎn)默認(rèn)頁(yè) (setClickNotificationToLaunchMainActivity 僅Android)

setClickNotificationToLaunchMainActivity
MobpushPlugin.setClickNotificationToLaunchMainActivity (bool enable);

移除本地通知(removeLocalNotification 僅Android)

removeLocalNotification
MobpushPlugin.removeLocalNotification(int notificationId);

清空本地通知(clearLocalNotifications 僅)

clearLocalNotifications
MobpushPlugin.clearLocalNotifications();

設(shè)置通知欄icon,不設(shè)置默認(rèn)取應(yīng)用icon(setNotifyIcon 僅Android)

setNotifyIcon
MobpushPlugin.setNotifyIcon(String resId);

設(shè)置通知靜音時(shí)段(推送選項(xiàng))(setSilenceTime 僅Android)

setSilenceTime
/**
   * 設(shè)置通知靜音時(shí)段(推送選項(xiàng))(僅Android)
   * @param startHour   開(kāi)始時(shí)間[0~23] (小時(shí))
   * @param startMinute 開(kāi)始時(shí)間[0~59](分鐘)
   * @param endHour     結(jié)束時(shí)間[0~23](小時(shí))
   * @param endMinute   結(jié)束時(shí)間[0~59](分鐘)
   */
MobpushPlugin.setSilenceTime(int startHour, int startMinute, int endHour, int endMinute)

設(shè)置角標(biāo) (setBadge僅 iOS)

setBadge
MobpushPlugin.setBadge(int badge);

清空角標(biāo),不清除通知欄消息記錄 (clearBadge僅 iOS)

clearBadge
MobpushPlugin.clearBadge();

獲取注冊(cè)Id(getRegistrationId)

getRegistrationId
MobpushPlugin.getRegistrationId().then((Map<String, dynamic> ridMap) {
    print(ridMap);
    String regId = ridMap['res'].toString();
    print('------>#### registrationId: ' + regId);
});

Flutter iOS端注意事項(xiàng)

由于插件更新,SDK的Pod依賴被替換,F(xiàn)lutter 本身寫(xiě)入Pod文件不會(huì)先執(zhí)行刪除原有依賴,導(dǎo)致可能會(huì)出現(xiàn)原有本地庫(kù)依然存在,請(qǐng)檢查Pod文件夾下文件,直接手動(dòng)刪除mob_pushsdk 以及 MOBFoundation文件即可,如有疑問(wèn),請(qǐng)直接通過(guò)官網(wǎng)和我們聯(lián)系。

demo地址 GitHub地址

以上就是MobPush for Flutter集成準(zhǔn)備的詳細(xì)內(nèi)容,更多關(guān)于MobPush for Flutter的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論