keySet = bundle.keySet();
98 | for (String key : keySet) {
99 | System.out.println("MobPush linkone bundle------------->" + key);
100 | System.out.println("MobPush linkone bundle------------->" + bundle.get(key));
101 | }
102 | }
103 | tv.setText(sb);
104 | }
105 |
106 | @Override
107 | public void onClick(View v) {
108 | switch (v.getId()) {
109 | case R.id.ivBack: {
110 | finish();
111 | }
112 | break;
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/java/com/mob/mobpush_example/LinkTwoActivity.java:
--------------------------------------------------------------------------------
1 | package com.mob.mobpush_example;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * scheme指定界面跳转目标页-指定界面2
13 | * 推送时通过scheme指定界面跳转,在AndroidManifest.xml文件中配置示例:
14 | *
16 | *
17 | *
18 | *
19 | *
22 | *
23 | *
24 | * 需添加intent-filter,配置相关action、category和data信息
25 | * 通过scheme://host格式填写scheme字段信息来进行指定界面推送。
26 | * 如果scheme指定界面携带附加数据,MobPush、魅族、小米、华为等四个推送通道进行了默认处理,把指定界面的附加数据统一放入了"data"的intent extra中,
27 | * 可通过getIntent().getExtras.get("data")获取附加数据;
28 | * 而FCM(应用非前台情况下)、OPPO通道的特殊性,无法进行默认处理,需在启动页中获取附加字段单独处理界面跳转和附加数据的传入。
29 | */
30 | public class LinkTwoActivity extends Activity implements View.OnClickListener {
31 | private final static String MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY = "data";
32 |
33 | private TextView tvTitle;
34 | private ImageView ivBack;
35 | private TextView tv;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.act_link_two);
41 | findView();
42 | initView();
43 | initData();
44 | }
45 |
46 | private void findView() {
47 | tvTitle = findViewById(R.id.tvTitle);
48 | ivBack = findViewById(R.id.ivBack);
49 | tv = findViewById(R.id.tv);
50 | }
51 |
52 | private void initView() {
53 | tvTitle.setText(R.string.link_two_title);
54 | ivBack.setOnClickListener(this);
55 | }
56 |
57 | private void initData() {
58 | Intent intent = getIntent();
59 | Uri uri = intent.getData();
60 | StringBuilder sb = new StringBuilder();
61 | if (uri != null) {
62 | sb.append(" scheme:" + uri.getScheme() + "\n");
63 | sb.append(" host:" + uri.getHost() + "\n");
64 | // sb.append(" port:" + uri.getPort() + "\n");
65 | // sb.append(" query:" + uri.getQuery() + "\n");
66 | }
67 |
68 | //获取link界面传输的数据,取字段data数据
69 | Bundle bundle = intent.getExtras();
70 | if (bundle != null && bundle.containsKey(MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY)) {
71 | sb.append(" extras:" + (bundle.containsKey(MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY)
72 | ? bundle.get(MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY).toString() : ""));
73 | }
74 | tv.setText(sb);
75 | }
76 |
77 | @Override
78 | public void onClick(View v) {
79 | switch (v.getId()) {
80 | case R.id.ivBack: {
81 | finish();
82 | }
83 | break;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/java/com/mob/mobpush_example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.mob.mobpush_example;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import com.mob.flutter.mobpush.MobpushPlugin;
10 | import com.mob.mobpush_example.utils.PlayloadDelegate;
11 | import com.mob.pushsdk.MobPush;
12 | import com.mob.pushsdk.MobPushUtils;
13 |
14 | import io.flutter.embedding.android.FlutterActivity;
15 | import io.flutter.embedding.engine.FlutterEngine;
16 | import io.flutter.plugins.GeneratedPluginRegistrant;
17 |
18 | public class MainActivity extends FlutterActivity {
19 | @Override
20 | public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
21 | super.configureFlutterEngine(flutterEngine);
22 | GeneratedPluginRegistrant.registerWith(flutterEngine);
23 | }
24 |
25 | @Override
26 | protected void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | MobpushPlugin.parseManufacturerMessage(getIntent());
29 | dealPushResponse(getIntent());
30 | }
31 |
32 | @Override
33 | protected void onNewIntent(Intent intent) {
34 | super.onNewIntent(intent);
35 | //需要调用setIntent方法,不然后面获取到的getIntent都试上一次传的数据
36 | setIntent(intent);
37 | MobpushPlugin.parseManufacturerMessage(intent);
38 | dealPushResponse(intent);
39 | }
40 | private void dealPushResponse(Intent intent) {
41 | Bundle bundle = null;
42 | if (intent != null) {
43 | MobPush.notificationClickAck(intent);
44 | MobPushUtils.parseMainPluginPushIntent(intent);
45 | bundle = intent.getExtras();
46 | new PlayloadDelegate().playload(this, bundle);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/java/com/mob/mobpush_example/utils/PlayloadDelegate.java:
--------------------------------------------------------------------------------
1 | package com.mob.mobpush_example.utils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.text.TextUtils;
8 | import android.util.Log;
9 |
10 | import com.mob.mobpush_example.web.WebViewPage;
11 | import com.mob.pushsdk.MobPushNotifyMessage;
12 | import com.mob.tools.utils.Hashon;
13 |
14 | import java.util.HashMap;
15 | import java.util.Set;
16 |
17 |
18 | /**
19 | * 推送消息携带附加数据处理类
20 | * >.附加数据的获取可在点击通知的落地页里的onCreate()或onNewIntent()里通过相关Intent的getExtras进行获取
21 | * >.落地页的附加数据大致分两种情况:1>MobPush自身通道和小米、魅族、华为三大厂商通道:
22 | * 1>默认落地页的情况下,针对MobPush自身通道和小米、魅族、华为三大厂商通道,需通过[msg]固定的key来获取数据
23 | * 2>配置scheme指定页的情况下,针对MobPush自身通道和小米、魅族、华为三大厂商通道,MobPush内部已经处理跳转指定页,并可通过Intent的getExtras用[data]进行获取指定页的附加数据
24 | *
25 | * 2>OPPO通道:默认落地页和配置scheme指定页都是打开默认启动页(OPPO系统控制打开默认启动页),在默认启动页中
26 | * 附加数据都在[pluginExtra]的固定key中获取,如果配置了scheme指定页,对于OPPO通道来说是不生效的,需自行在代码
27 | * 中通过[mobpush_link_k]来获取scheme处理跳转,如果同时携带了scheme的附加数据则需通过[mobpush_link_v]获取数据
28 | *
29 | * 3>FCM通道: 默认落地页和配置scheme指定页都是打开默认启动页(google 服务控制打开默认启动页),而且附加字段完全暴露在从Intent的getExtras的Bundle中,
30 | * 配置了scheme,对于FCM通道来说也是不生效的,需自行在代码中通过[mobpush_link_k]来获取scheme处理跳转,如果同时携带了scheme的附加数据则需通过[mobpush_link_v]获取数据
31 | */
32 | public class PlayloadDelegate {
33 | //固定推送附加字段:
34 | private final static String MOB_PUSH_SCHEME_KEY = "mobpush_link_k";
35 | private final static String MOB_PUSH_SCHEME_PLAYLOAD_KEY = "mobpush_link_v";
36 | private final static String MOB_PUSH_OPPO_EXTRA_DATA = "pluginExtra";
37 | private final static String MOB_PUSH_NORMAL_PLAYLOAD_KEY = "msg";
38 | private final static String MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY = "data";
39 |
40 | //如果是从后台的扩展参数传,则可以随意定义:
41 | private final static String MOB_PUSH_DEMO_URL = "url";
42 |
43 | public void playload(Context context, Bundle bundle) {
44 | try {
45 | if (bundle == null) {
46 | return;
47 | }
48 |
49 | Set keySet = bundle.keySet();
50 | if (keySet == null || keySet.isEmpty()) {
51 | return;
52 | }
53 | HashMap map = new HashMap();
54 | for (String key : keySet) {
55 | System.out.println("MobPush playload bundle------------->" + key);
56 | System.out.println("MobPush playload bundle------------->" + bundle.get(key));
57 |
58 | if (key.equals(MOB_PUSH_OPPO_EXTRA_DATA)) {
59 | map = parseOPPOPlayload(bundle);
60 |
61 | } else if (key.equals(MOB_PUSH_NORMAL_PLAYLOAD_KEY)) {
62 | map = parseNormalPlayload(bundle);
63 |
64 | } else {
65 | Object object = bundle.get(key);
66 | System.out.println(">>>>>>key: " + key + ", object: " + object);
67 | map.put(key, String.valueOf(object));
68 | }
69 | }
70 |
71 | if (map != null && !map.isEmpty()) {
72 | realPerform(context, map);
73 | }
74 | } catch (Throwable throwable) {
75 | Log.e("MobPush playload", throwable.getMessage());
76 | }
77 | }
78 |
79 | private void realPerform(Context context, HashMap map) {
80 | if (map == null) {
81 | return;
82 | }
83 | String json = "";
84 |
85 | Set keys = map.keySet();
86 | for (String key : keys) {
87 | System.out.println(">>>>>>>>>>all key: " + key + ", value: " + map.get(key));
88 | }
89 |
90 | if (keys != null && keys.size() == 1 && (keys.contains("profile") || keys.contains("workId"))) {
91 | return;
92 | }
93 |
94 | for (String key : keys) {
95 | if (!"profile".equals(key) && !"workId".equals(key)
96 | && !"collapse_key".equals(key) && !key.startsWith("google.") && !"from".equals(key)) {
97 | json += "key: " + key + ", value: " + map.get(key) + "\n";
98 | }
99 | }
100 | // Toast.makeText(context, json, Toast.LENGTH_SHORT).show();
101 |
102 | //通过配置scheme跳转指定界面则需使用固定的key来获取相关数据
103 | if (map.containsKey(MOB_PUSH_SCHEME_KEY)) {
104 | openAct(context, map);
105 | } else {
106 | //处理其他自定义数据的业务逻辑,例如打开网页:通过自定义的key来获取对应的数据
107 | if (map.containsKey(MOB_PUSH_DEMO_URL)) {
108 | openUrl(context, map);
109 | } else if (map.containsKey(MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY)) {
110 | System.out.println(">>>>>>>>>>scheme Activity with playload data: " + MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY + ", value: " + map.get(MOB_PUSH_NORMAL_SCHEME_PLAYLOAD_KEY));
111 | } else {
112 |
113 | }
114 | }
115 | }
116 |
117 | private HashMap parseOPPOPlayload(Bundle bundle) {
118 | HashMap hashMap = null;
119 | String v = String.valueOf(bundle.get(MOB_PUSH_OPPO_EXTRA_DATA));
120 | if (!TextUtils.isEmpty(v)) {
121 | hashMap = new Hashon().fromJson(v);
122 | }
123 | return hashMap;
124 | }
125 |
126 | private HashMap parseNormalPlayload(Bundle bundle) {
127 | HashMap hashMap = null;
128 | try {
129 | MobPushNotifyMessage notifyMessage = (MobPushNotifyMessage) bundle.getSerializable(MOB_PUSH_NORMAL_PLAYLOAD_KEY);
130 | if (notifyMessage != null) {
131 | hashMap = notifyMessage.getExtrasMap();
132 | }
133 | } catch (Throwable throwable) {
134 | Log.e("MobPush", throwable.getMessage());
135 | hashMap = new HashMap();
136 | }
137 | return hashMap;
138 | }
139 |
140 | private void openUrl(Context context, HashMap params) {
141 | String url;
142 | if (!TextUtils.isEmpty((CharSequence) params.get(MOB_PUSH_DEMO_URL))) {
143 | url = (String) params.get(MOB_PUSH_DEMO_URL);
144 | } else {
145 | url = "http://m.mob.com";
146 | }
147 | if (!url.startsWith("http://") && !url.startsWith("https://")) {
148 | url = "http://" + url;
149 | }
150 | System.out.println("url:" + url);
151 | WebViewPage webViewPage = new WebViewPage();
152 | webViewPage.setJumpUrl(url);
153 | webViewPage.show(context, null);
154 | }
155 |
156 | private void openAct(Context context, HashMap params) {
157 | String uri = params.containsKey(MOB_PUSH_SCHEME_KEY) ? (String) params.get(MOB_PUSH_SCHEME_KEY) : "";
158 | if (TextUtils.isEmpty(uri)) {
159 | return;
160 | }
161 | Intent intent = new Intent(null, Uri.parse(uri));
162 | intent.setPackage(context.getPackageName());
163 | if (params.containsKey(MOB_PUSH_SCHEME_PLAYLOAD_KEY) && params.get(MOB_PUSH_SCHEME_PLAYLOAD_KEY) != null) {
164 | intent.putExtra("data", (String) params.get(MOB_PUSH_SCHEME_PLAYLOAD_KEY));
165 | }
166 | context.startActivity(intent);
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/java/com/mob/mobpush_example/utils/SizeHelper.java:
--------------------------------------------------------------------------------
1 | package com.mob.mobpush_example.utils;
2 |
3 | import android.content.Context;
4 |
5 | import com.mob.tools.utils.ResHelper;
6 |
7 |
8 | public class SizeHelper {
9 | public static float designedDensity = 1.5f;
10 | public static int designedScreenWidth = 540;
11 | private static Context context = null;
12 |
13 | protected static SizeHelper helper;
14 |
15 | private SizeHelper() {
16 | }
17 |
18 | public static void prepare(Context c) {
19 | if (context == null || context != c.getApplicationContext()) {
20 | context = c;
21 | }
22 | }
23 |
24 | /**
25 | * 根据density转换设计的px到目标机器,返回px大小
26 | *
27 | * @return 像素大小
28 | */
29 | public static int fromPx(int px) {
30 | return ResHelper.designToDevice(context, designedDensity, px);
31 | }
32 |
33 | /**
34 | * 根据屏幕宽度转换设计的px到目标机器,返回px大小
35 | *
36 | * @return 像素大小
37 | */
38 | public static int fromPxWidth(int px) {
39 | return ResHelper.designToDevice(context, designedScreenWidth, px);
40 | }
41 |
42 | /**
43 | * 根据density转换设计的dp到目标机器,返回px大小
44 | *
45 | * @return 像素大小
46 | */
47 | public static int fromDp(int dp) {
48 | int px = ResHelper.dipToPx(context, dp);
49 | return ResHelper.designToDevice(context, designedDensity, px);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/java/com/mob/mobpush_example/web/BaseWebView.java:
--------------------------------------------------------------------------------
1 | package com.mob.mobpush_example.web;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.util.AttributeSet;
6 | import android.webkit.WebSettings;
7 | import android.webkit.WebView;
8 |
9 | public class BaseWebView extends WebView {
10 |
11 | public BaseWebView(Context context) {
12 | super(context);
13 | initSettings();
14 | }
15 |
16 | public BaseWebView(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | initSettings();
19 | }
20 |
21 | public BaseWebView(Context context, AttributeSet attrs, int defStyleAttr) {
22 | super(context, attrs, defStyleAttr);
23 | initSettings();
24 | if (Build.VERSION.SDK_INT >= 11) {
25 | removeJavascriptInterface("searchBoxJavaBridge_");
26 | removeJavascriptInterface("accessibility");
27 | removeJavascriptInterface("accessibilityTraversal");
28 | }
29 | }
30 |
31 | private void initSettings() {
32 | WebSettings settings = getSettings();
33 | settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
34 | settings.setUseWideViewPort(true);
35 | settings.setJavaScriptEnabled(true);
36 | // settings.setDomStorageEnabled(true);
37 | setVerticalScrollBarEnabled(false);
38 | setHorizontalScrollBarEnabled(false);
39 | settings.setAppCacheEnabled(false);
40 | // settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
41 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
42 | getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
43 | }
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/java/com/mob/mobpush_example/web/WebViewPage.java:
--------------------------------------------------------------------------------
1 | package com.mob.mobpush_example.web;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.graphics.Bitmap;
7 | import android.graphics.drawable.ColorDrawable;
8 | import android.net.Uri;
9 | import android.net.http.SslError;
10 | import android.util.TypedValue;
11 | import android.view.Gravity;
12 | import android.view.KeyEvent;
13 | import android.view.View;
14 | import android.view.Window;
15 | import android.webkit.SslErrorHandler;
16 | import android.webkit.WebChromeClient;
17 | import android.webkit.WebView;
18 | import android.webkit.WebViewClient;
19 | import android.widget.ImageView;
20 | import android.widget.LinearLayout;
21 | import android.widget.LinearLayout.LayoutParams;
22 | import android.widget.ProgressBar;
23 | import android.widget.TextView;
24 |
25 | import com.mob.mobpush_example.utils.SizeHelper;
26 | import com.mob.tools.FakeActivity;
27 | import com.mob.tools.utils.ResHelper;
28 |
29 | /**
30 | * Created by yychen on 2017/11/2.
31 | */
32 |
33 | public class WebViewPage extends FakeActivity {
34 | private LinearLayout mainlayout;
35 | private ImageView ivBack;
36 | private TextView tvTitle;
37 | private ProgressBar progressBar;
38 | private BaseWebView webView;
39 | private String url;
40 |
41 | @Override
42 | public void onCreate() {
43 | Window window = activity.getWindow();
44 | window.setBackgroundDrawable(new ColorDrawable(0xFFFFFFFF));
45 | initPage(activity);
46 | activity.setContentView(mainlayout);
47 | }
48 |
49 | public void setJumpUrl(String url) {
50 | this.url = url;
51 | }
52 |
53 | private void initPage(final Activity activity) {
54 | initView();
55 |
56 | webView.setWebViewClient(new WebViewClient() {
57 | private String startUrl;
58 |
59 | @Override
60 | public void onPageStarted(WebView view, String url, Bitmap favicon) {
61 | super.onPageStarted(view, url, favicon);
62 | startUrl = url;
63 | }
64 |
65 | public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
66 | handler.proceed();
67 | }
68 |
69 | @Override
70 | public boolean shouldOverrideUrlLoading(WebView view, String url1) {
71 | if (url1 == null) return false;
72 | try {
73 | if (!url1.startsWith("http://") && !url1.startsWith("https://")) {
74 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url1));
75 | startActivity(intent);
76 | return false;
77 | }
78 | } catch (Exception e) {
79 | // //防止crash (如果手机上没有安装处理某个scheme开头的url的APP, 会导致crash)
80 | return true;//没有安装该app时,返回true,表示拦截自定义链接,但不跳转,避免弹出上面的错误页面
81 | }
82 |
83 | //返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器
84 | if (startUrl != null && startUrl.equals(url)) {
85 | view.loadUrl(url);
86 | } else {
87 | //交给系统处理
88 | return super.shouldOverrideUrlLoading(view, url);
89 | }
90 | return true;
91 | }
92 |
93 | public void onPageFinished(WebView view, String url) {
94 | super.onPageFinished(view, url);
95 | if (view != null) {
96 | tvTitle.setText(view.getTitle());
97 | }
98 | }
99 | });
100 | webView.setWebChromeClient(new WebChromeClient() {
101 | public void onProgressChanged(WebView view, int newProgress) {
102 | progressBar.setProgress(newProgress);
103 | if (newProgress == 100) {
104 | progressBar.setVisibility(View.GONE);
105 | } else if (progressBar.getVisibility() == View.GONE) {
106 | progressBar.setVisibility(View.VISIBLE);
107 | }
108 | super.onProgressChanged(view, newProgress);
109 | }
110 | });
111 |
112 | webView.loadUrl(url);
113 | ivBack.setOnClickListener(new View.OnClickListener() {
114 | @Override
115 | public void onClick(View view) {
116 | if (webView != null && webView.canGoBack()) {
117 | webView.goBack();
118 | } else {
119 | finishOnSuccess();
120 | }
121 | }
122 | });
123 | }
124 |
125 | @SuppressLint("WrongConstant")
126 | private void initView() {
127 | SizeHelper.prepare(getContext());
128 | int px2 = SizeHelper.fromPxWidth(2);
129 | int px3 = SizeHelper.fromPxWidth(3);
130 | int px15 = SizeHelper.fromPxWidth(15);
131 | int px30 = SizeHelper.fromPxWidth(30);
132 |
133 | mainlayout = new LinearLayout(getContext());
134 | mainlayout.setOrientation(LinearLayout.VERTICAL);
135 | LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
136 |
137 | LinearLayout titlelayout = new LinearLayout(getContext());
138 | titlelayout.setPadding(px15, 0, px15, 0);
139 | lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 1);
140 | mainlayout.addView(titlelayout, lp);
141 |
142 | ivBack = new ImageView(getContext());
143 | ivBack.setScaleType(ImageView.ScaleType.CENTER_CROP);
144 | ivBack.setImageResource(ResHelper.getBitmapRes(getContext(), "ic_back"));
145 | lp = new LayoutParams(px30, px30);
146 | lp.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
147 | titlelayout.addView(ivBack, lp);
148 |
149 | tvTitle = new TextView(getContext());
150 | tvTitle.setGravity(Gravity.CENTER);
151 | tvTitle.setMaxLines(1);
152 | tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(22));
153 | tvTitle.setTextColor(0xff1e1e1e);
154 | lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
155 | lp.gravity = Gravity.CENTER_VERTICAL;
156 | lp.leftMargin = px15;
157 | titlelayout.addView(tvTitle, lp);
158 |
159 | //分割线
160 | View line = new View(getContext());
161 | line.setBackgroundColor(0xffe8e8e8);
162 | lp = new LayoutParams(LayoutParams.MATCH_PARENT, px2);
163 | mainlayout.addView(line, lp);
164 |
165 | progressBar = new ProgressBar(getContext(), null, android.R.style.Widget_ProgressBar_Horizontal);
166 | progressBar.setMax(100);
167 | progressBar.setIndeterminate(false);
168 | lp = new LayoutParams(LayoutParams.MATCH_PARENT, px3);
169 | mainlayout.addView(progressBar, lp);
170 | progressBar.setProgressDrawable(activity.getResources().getDrawable(ResHelper.getBitmapRes(getContext(), "webview_progressbar_bg")));
171 |
172 | webView = new BaseWebView(getContext());
173 | lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 11);
174 | mainlayout.addView(webView, lp);
175 | }
176 |
177 | public boolean onKeyEvent(int keyCode, KeyEvent event) {
178 | if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
179 | if (webView != null && webView.canGoBack()) {
180 | webView.goBack();
181 | } else {
182 | finishOnSuccess();
183 | }
184 | return true;
185 | }
186 | return super.onKeyEvent(keyCode, event);
187 | }
188 |
189 | public void finishOnSuccess() {
190 | finish();
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/drawable/webview_progressbar_bg.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/layout/act_link_one.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/layout/act_link_two.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/layout/title_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
22 |
23 |
28 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_back.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MobPush
3 | 选择你想测试的推送类型
4 | App内推送
5 | App内推送测试
6 | 通知
7 | 通知测试
8 | 定时通知
9 | 定时通知测试
10 | 本地通知
11 | 通过推送打开指定链接页面
12 | 设置
13 | 创建NotificationChannel
14 | 本地通知提醒测试
15 | 点击测试按钮后,你将立即收到一条app内推送
16 | 填写推送内容(不超过35个字)
17 | 点击测试
18 | 跳转URL
19 | 请填写URL地址,为空则跳转至mob官网
20 | 系统推送通知内容
21 | 点击测试按钮后,请在前台关闭App,5s后你将收到一条测试通知
22 | 点击测试按钮后,请在前台关闭App,在你设定的时间到了时你将收到一条测试通知
23 | 编辑完成后,点击测试按钮,你将立即收到一条推送消息,点击后可跳转至指定页面。
24 | 设置时间后点击测试按钮,请在前台关闭App,在你设定的时间到了时你将收到本地通知提醒
25 | 此时间只为方便测试功能,后台使用时不可设定1小时内的定时推送
26 | 立即
27 | 1分钟后
28 | 2分钟后
29 | 3分钟后
30 | 4分钟后
31 | 5分钟后
32 | 推送内容不能为空
33 | 发送成功
34 | 发送失败,请检查网络重试
35 | 收到推送
36 | 我知道了
37 | 此推送服务由MobPush提供
38 | 推送发送成功!请在前台关闭app,5S后你将收到一条测试通知
39 | 推送发送成功!请在前台关闭app,%s后你将收到一条测试通知
40 | 推送发送成功!请在前台关闭app,5S后你将收到一条打开链接的消息
41 |
42 | 程序抢修中,请稍后重试~
43 | 网络不给力,请检查网络后再试~
44 | mobPush
45 |
46 |
47 | 推送打开应用内指定页面
48 | 打开应用内指定页面测试
49 | 编辑完成后,点击测试按钮后,你将立即收到一条推送消息,点击后可跳转至指定的应用内页面
50 | 填写推送内容(字数不超过35个字)
51 | 推送打开首页
52 | 推送打开指定界面1
53 | 推送打开指定界面2
54 | 通知测试页面
55 | 推送发送成功!你将收到一条能跳转至应用内指定页面的通知
56 | Link打开指定界面1
57 | Link打开指定界面2
58 | Link Activity Success.
59 | 通知权限已关闭
60 |
61 | 设置
62 | 隐私协议开关
63 | 获取rid
64 | 获取厂商token
65 | 设置大图标
66 | 去除大图标
67 | 设置自定义通知
68 | 移除自定义通知
69 | 设置前台时不显示推送
70 | 设置前台时显示推送
71 | 绑定手机号
72 | 获取手机号
73 | 请输入内容
74 | 取消
75 | 确定
76 | 设置手机号成功
77 | 设置手机号失败
78 | 请输入正确的手机号
79 | 设置别名
80 | 删除别名
81 | 获取别名
82 | 添加标签
83 | 删除标签
84 | 获取标签
85 | 清空标签
86 |
87 | 显示角标
88 | 不显示角标
89 | 获取是否显示角标
90 | 设置角标数
91 | 请输入角标数
92 |
93 | 推送本地通知
94 | 移除本地通知
95 | 清除本地通知
96 | 清除所有通知(包括MobPush通道和厂商通道通知,其中华为、小米、魅族厂商通道有效,其他厂商通道无效)
97 | 清除角标
98 |
99 | 启用Push
100 | 停用Push
101 |
102 | 通知通道ID
103 | 通知通道Name
104 | 通知通道重要性
105 | 创建通知通道
106 | tcp状态检测
107 | 开启通知栏权限监控
108 | 关闭通知栏权限监控
109 | startTest
110 | 显示最大通知个数
111 | 请输入最大通知个数
112 | 是否设置notification group属性
113 | 请输入通知事件1~9,以英文,隔开
114 | 设置刷新触发事件
115 |
116 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven {
4 | url "https://mvn.mob.com/android"
5 | }
6 | maven { url 'https://developer.huawei.com/repo/' }
7 | google()
8 | mavenCentral()
9 | }
10 |
11 | // 标准: 必须添加 classpath 'com.android.tools.build:gradle:3.2.1'
12 | // classpath 'com.mob.sdk:MobSDK:+'
13 | // 其他根据业务需要添加
14 | dependencies {
15 | classpath 'com.android.tools.build:gradle:3.6.0'
16 | classpath 'com.mob.sdk:MobSDK:+'
17 | classpath 'com.google.gms:google-services:4.3.3' // google-services plugin
18 | classpath 'com.huawei.agconnect:agcp:1.2.0.300'
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | maven {
25 | url "https://mvn.mob.com/android"
26 | }
27 | maven { url 'https://developer.huawei.com/repo/' }
28 | google()
29 | mavenCentral()
30 | }
31 | }
32 |
33 | rootProject.buildDir = '../build'
34 | subprojects {
35 | project.buildDir = "${rootProject.buildDir}/${project.name}"
36 | }
37 | subprojects {
38 | project.evaluationDependsOn(':app')
39 | }
40 |
41 | tasks.register('clean', Delete) {
42 | delete rootProject.buildDir
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
--------------------------------------------------------------------------------
/mobpush_plugin/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/assets/images/ic_item_app_nitify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/assets/images/ic_item_app_nitify.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/assets/images/ic_item_local.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/assets/images/ic_item_local.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/assets/images/ic_item_media.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/assets/images/ic_item_media.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/assets/images/ic_item_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/assets/images/ic_item_notify.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/assets/images/ic_item_open_act.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/assets/images/ic_item_open_act.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/assets/images/ic_item_timing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/assets/images/ic_item_timing.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 9.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Flutter/Flutter.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # NOTE: This podspec is NOT to be published. It is only used as a local source!
3 | # This is a generated file; do not edit or check into version control.
4 | #
5 |
6 | Pod::Spec.new do |s|
7 | s.name = 'Flutter'
8 | s.version = '1.0.0'
9 | s.summary = 'High-performance, high-fidelity mobile apps.'
10 | s.homepage = 'https://flutter.io'
11 | s.license = { :type => 'MIT' }
12 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
13 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
14 | s.ios.deployment_target = '9.0'
15 | # Framework linking is handled by Flutter tooling, not CocoaPods.
16 | # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
17 | s.vendored_frameworks = 'path/to/nothing'
18 | end
19 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Flutter/flutter_export_environment.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # This is a generated file; do not edit or check into version control.
3 | export "FLUTTER_ROOT=/Users/mobtech-ios/Documents/Projects/Flutter"
4 | export "FLUTTER_APPLICATION_PATH=/Users/mobtech-ios/Documents/Projects/Push_Flutter/mobpush_plugin/example"
5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6 | export "FLUTTER_TARGET=lib/main.dart"
7 | export "FLUTTER_BUILD_DIR=build"
8 | export "FLUTTER_BUILD_NAME=1.0.0"
9 | export "FLUTTER_BUILD_NUMBER=1"
10 | export "DART_OBFUSCATION=false"
11 | export "TRACK_WIDGET_CREATION=false"
12 | export "TREE_SHAKE_ICONS=true"
13 | export "PACKAGE_CONFIG=/Users/mobtech-ios/Documents/Projects/Push_Flutter/mobpush_plugin/example/.dart_tool/package_config.json"
14 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
32 | end
33 |
34 | post_install do |installer|
35 | installer.pods_project.targets.each do |target|
36 | flutter_additional_ios_build_settings(target)
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Flutter (1.0.0)
3 | - FlyVerifyCSDK (1.0.4)
4 | - mob_pushsdk (4.2.6):
5 | - mob_pushsdk/MobPush (= 4.2.6)
6 | - MOBFoundation
7 | - mob_pushsdk/MobPush (4.2.6):
8 | - MOBFoundation
9 | - MOBFoundation (20250221):
10 | - FlyVerifyCSDK (>= 0.0.7)
11 | - mobpush_plugin (1.1.0):
12 | - Flutter
13 | - mob_pushsdk
14 |
15 | DEPENDENCIES:
16 | - Flutter (from `Flutter`)
17 | - mobpush_plugin (from `.symlinks/plugins/mobpush_plugin/ios`)
18 |
19 | SPEC REPOS:
20 | trunk:
21 | - FlyVerifyCSDK
22 | - mob_pushsdk
23 | - MOBFoundation
24 |
25 | EXTERNAL SOURCES:
26 | Flutter:
27 | :path: Flutter
28 | mobpush_plugin:
29 | :path: ".symlinks/plugins/mobpush_plugin/ios"
30 |
31 | SPEC CHECKSUMS:
32 | Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
33 | FlyVerifyCSDK: 6abc7ed81b332f69f72e1e113990cfd88fc335f0
34 | mob_pushsdk: 873fb39cd315ca2d342da25c00273a67273ea4b3
35 | MOBFoundation: 600c32f816bd0ebf5e2048c8e40357217d22ea9c
36 | mobpush_plugin: c7924c87d18b622e0bda192bb841fb3e1a13326a
37 |
38 | PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d
39 |
40 | COCOAPODS: 1.16.2
41 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | mobpush_plugin_example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(MARKETING_VERSION)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSAllowsArbitraryLoads
28 |
29 |
30 | UIBackgroundModes
31 |
32 | remote-notification
33 | fetch
34 |
35 | UILaunchStoryboardName
36 | LaunchScreen
37 | UIMainStoryboardFile
38 | Main
39 | UISupportedInterfaceOrientations
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationLandscapeLeft
43 | UIInterfaceOrientationLandscapeRight
44 |
45 | UISupportedInterfaceOrientations~ipad
46 |
47 | UIInterfaceOrientationPortrait
48 | UIInterfaceOrientationPortraitUpsideDown
49 | UIInterfaceOrientationLandscapeLeft
50 | UIInterfaceOrientationLandscapeRight
51 |
52 | UIViewControllerBasedStatusBarAppearance
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/Runner.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 |
8 |
9 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/lib/app_notify_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:mobpush_plugin/mobpush_plugin.dart';
3 |
4 | class AppNotifyPage extends StatefulWidget {
5 | @override
6 | _AppNotifyPageState createState() {
7 | return new _AppNotifyPageState();
8 | }
9 | }
10 |
11 | class _AppNotifyPageState extends State {
12 | TextEditingController _controller = new TextEditingController();
13 |
14 | void _send() async {
15 | if (_controller.text.isNotEmpty) {
16 | //发送消息类型为2的自定义透传消息,推送内容时输入框输入的内容,延迟推送时间为0(立即推送),附加数据为空
17 | MobpushPlugin.send(2, _controller.text, 0, '').then((Map sendMap){
18 | String res = sendMap['res'];
19 | String error = sendMap['error'];
20 | print(">>>>>>>>>>>>>>>>>>>>>>>>>>> send -> res: $res error: $error");
21 | });
22 | }
23 | }
24 |
25 | @override
26 | Widget build(BuildContext context) {
27 | return Scaffold(
28 | appBar: AppBar(
29 | title: Text('App内推送测试'),
30 | iconTheme: IconThemeData(color: Colors.black),
31 | textTheme: TextTheme(headline6: TextStyle(color: Colors.black)),
32 | backgroundColor: Colors.white,
33 | centerTitle: true,
34 | ),
35 | body: Container(
36 | margin: EdgeInsets.all(15.0),
37 | child: Column(
38 | crossAxisAlignment: CrossAxisAlignment.start,
39 | children: [
40 | Text(
41 | '点击测试按钮后,你将立即收到一条App内推送',
42 | textAlign: TextAlign.left,
43 | ),
44 | Container(
45 | margin: EdgeInsets.only(top: 10, bottom: 30),
46 | child: TextField(
47 | maxLines: 5,
48 | maxLength: 35,
49 | decoration: InputDecoration(
50 | hintText: '推送内容(不超过35个字)',
51 | contentPadding: EdgeInsets.all(10),
52 | border: OutlineInputBorder(
53 | borderRadius: BorderRadius.all(Radius.circular(5.0)),
54 | borderSide: BorderSide(
55 | color: Color(0xFFe1e1e1),
56 | width: 0.5,
57 | style: BorderStyle.solid,
58 | )
59 | )
60 | ),
61 | controller: _controller,
62 | ),
63 | ),
64 | Row(
65 | children: [
66 | new Expanded(
67 | child: new ElevatedButton(
68 | child: Text(
69 | '点击测试',
70 | style: new TextStyle(color: Colors.white),
71 | ),
72 | onPressed: _send,
73 | ),
74 | // child: new RaisedButton(
75 | // padding: EdgeInsets.symmetric(vertical: 12),
76 | // color: Color(0xFF7B91FF),
77 | // child: Text(
78 | // '点击测试',
79 | // style: new TextStyle(color: Colors.white),
80 | // ),
81 | // onPressed: _send,
82 | // ),
83 | )
84 | ],
85 | )
86 | ],
87 | ),
88 | ),
89 | );
90 | }
91 |
92 | }
--------------------------------------------------------------------------------
/mobpush_plugin/example/lib/click_container.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 |
4 | class ClickContainer extends StatefulWidget {
5 | final double left;
6 | final double top;
7 | final double right;
8 | final double bottom;
9 | final String res;
10 | final String content;
11 | final GestureTapCallback onTap;
12 |
13 | ClickContainer(
14 | {
15 | required this.content,
16 | required this.res,
17 | required this.left,
18 | required this.top,
19 | required this.right,
20 | required this.bottom,
21 | required this.onTap
22 | }
23 | );
24 |
25 | @override
26 | _ClickContainerState createState() {
27 | return _ClickContainerState();
28 | }
29 | }
30 |
31 | class _ClickContainerState extends State {
32 |
33 | @override
34 | Widget build(BuildContext context) {
35 | return new GestureDetector(
36 | child: Container(
37 | margin: EdgeInsets.only(left:widget.left, top: widget.top,
38 | right: widget.right, bottom:widget.bottom),
39 | decoration: BoxDecoration(
40 | color: Color(0xFFebf2ff),
41 | borderRadius: new BorderRadius.all(new Radius.circular(8.0)),
42 | ),
43 | child: Column(
44 | mainAxisAlignment: MainAxisAlignment.center,
45 | children: [
46 | Image.asset(widget.res),
47 | Text(widget.content)
48 | ],
49 | ),
50 | ),
51 | onTap: widget.onTap,
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/lib/local_notify_page.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 | import 'dart:math';
3 |
4 | import 'package:flutter/material.dart';
5 | import 'package:mobpush_plugin/mobpush_plugin.dart';
6 | import 'package:mobpush_plugin/mobpush_local_notification.dart';
7 |
8 | class LocalNotifyPage extends StatefulWidget {
9 | @override
10 | _LocalNotifyPageState createState() {
11 | return new _LocalNotifyPageState();
12 | }
13 | }
14 |
15 | class _LocalNotifyPageState extends State {
16 | TextEditingController _controller = new TextEditingController();
17 | void _send() async {
18 | if (_controller.text.isNotEmpty) {
19 | if (Platform.isIOS) { // iOS
20 | MobPushLocalNotification localNotification = new MobPushLocalNotification(
21 | title: "正标题",//本地通知标题
22 | content: _controller.text, //本地通知内容
23 | timestamp: 0, //本地通知时间戳, 0立刻通知。其余为时间间隔
24 | badge: 1, // ios角标
25 | sound: "default", // ios声音
26 | subTitle: "副标题",
27 | extrasMap: {"extra":"testExtra"} // ios副标题
28 | );// ios副标题
29 | await MobpushPlugin.addLocalNotification(localNotification);
30 | } else { // Android
31 | MobPushLocalNotification localNotification = new MobPushLocalNotification(
32 | notificationId: new Random().nextInt(99),//notificationId
33 | title: "本地通知",//本地通知标题
34 | content: _controller.text,//本地通知内容
35 | messageId: new Random().nextInt(999).toString(),//消息id
36 | inboxStyleContent: null,//收件箱样式的内容
37 | timestamp: new DateTime.now().millisecondsSinceEpoch,//本地通知时间戳
38 | style: 0,//通知样式
39 | channel: 0,//消息通道
40 | extrasMap: null,//附加数据
41 | voice: true,//声音
42 | shake: true,//真的
43 | styleContent: null,//大段文本和大图模式的样式内容
44 | light: true,//呼吸灯
45 | );
46 | await MobpushPlugin.addLocalNotification(localNotification);
47 | }
48 | }
49 | }
50 |
51 | @override
52 | Widget build(BuildContext context) {
53 | return Scaffold(
54 | appBar: AppBar(
55 | title: Text('本地通知提醒测试'),
56 | iconTheme: IconThemeData(color: Colors.black),
57 | textTheme: TextTheme(headline6: TextStyle(color: Colors.black)),
58 | backgroundColor: Colors.white,
59 | centerTitle: true,
60 | ),
61 | body: Container(
62 | margin: EdgeInsets.all(15.0),
63 | child: Column(
64 | crossAxisAlignment: CrossAxisAlignment.start,
65 | children: [
66 | Text(
67 | "点击测试按钮后,在你设定的时间到了时将收到一条本地通知提醒",
68 | textAlign: TextAlign.left,
69 | ),
70 | Container(
71 | margin: EdgeInsets.only(top: 10, bottom: 30),
72 | child: TextField(
73 | maxLines: 5,
74 | maxLength: 35,
75 | decoration: InputDecoration(
76 | hintText: "填写推送内容(不超过35个字)",
77 | contentPadding: EdgeInsets.all(10),
78 | border: OutlineInputBorder(
79 | borderRadius: BorderRadius.all(Radius.circular(5.0)),
80 | borderSide: BorderSide(
81 | color: Color(0xFFe1e1e1),
82 | width: 0.5,
83 | style: BorderStyle.solid
84 | )
85 | )
86 | ),
87 | controller: _controller,
88 | ),
89 | ),
90 | Row(
91 | children: [
92 | new Expanded(
93 | child: new ElevatedButton(
94 | child: Text(
95 | '点击测试',
96 | style: new TextStyle(color: Colors.white),
97 | ),
98 | onPressed: _send,
99 | ),
100 | // child: new RaisedButton(
101 | // padding: EdgeInsets.symmetric(vertical: 12),
102 | // color: Color(0xFFFF7D00),
103 | // child: Text(
104 | // '点击测试',
105 | // style: new TextStyle(color: Colors.white),
106 | // ),
107 | // onPressed: _send,
108 | // )
109 | ),
110 | ],
111 | ),
112 | ],
113 | ),
114 | )
115 | );
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'dart:ffi';
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 | import 'dart:async';
7 |
8 | import 'package:flutter/services.dart';
9 | import 'package:mobpush_plugin/mobpush_plugin.dart';
10 | import 'package:mobpush_plugin/mobpush_custom_message.dart';
11 | import 'package:mobpush_plugin/mobpush_notify_message.dart';
12 | import 'app_notify_page.dart';
13 | import 'click_container.dart';
14 | import 'local_notify_page.dart';
15 | import 'notify_page.dart';
16 | import 'other_api_page.dart';
17 | import 'timing_notify_page.dart';
18 |
19 | void main() => runApp(MyApp());
20 |
21 | class MyApp extends StatelessWidget {
22 | @override
23 | Widget build(BuildContext context) {
24 | return new MaterialApp(
25 | home: MainApp(),
26 | );
27 | }
28 | }
29 |
30 | class MainApp extends StatefulWidget {
31 | @override
32 | _MainAppState createState() {
33 | return _MainAppState();
34 | }
35 | }
36 |
37 | class _MainAppState extends State {
38 | String _sdkVersion = 'Unknown';
39 | String _registrationId = 'Unknown';
40 |
41 | @override
42 | void initState() {
43 | super.initState();
44 | //上传隐私协议许可
45 | MobpushPlugin.updatePrivacyPermissionStatus(true).then((value) {
46 | print(">>>>>>>>>>>>>>>>>>>updatePrivacyPermissionStatus:" +
47 | value.toString());
48 | });
49 | if (Platform.isIOS) {
50 | //设置地区:regionId 默认0(国内),1:海外
51 | MobpushPlugin.setRegionId(0);
52 | MobpushPlugin.registerApp("3276d3e413040", "4280a3a6df667cfce37528dec03fd9c3");
53 | }
54 |
55 | initPlatformState();
56 |
57 | if (Platform.isIOS) {
58 | MobpushPlugin.setCustomNotification();
59 | MobpushPlugin.setAPNsForProduction(true);
60 | }
61 | MobpushPlugin.addPushReceiver(_onEvent, _onError);
62 |
63 | }
64 |
65 | void _onEvent(dynamic event) {
66 | print('>>>>>>>>>>>>>>>>>>>>>>>>>>>onEvent:' + event.toString());
67 | setState(() {
68 | Map eventMap = json.decode(event as String);
69 | Map result = eventMap['result'];
70 | int action = eventMap['action'];
71 |
72 | switch (action) {
73 | case 0:
74 | MobPushCustomMessage message =
75 | new MobPushCustomMessage.fromJson(result);
76 | showDialog(
77 | context: context,
78 | builder: (context) {
79 | return AlertDialog(
80 | content: Text(message.content),
81 | actions: [
82 | TextButton(
83 | onPressed: () {
84 | Navigator.pop(context);
85 | },
86 | child: Text("确定")
87 | )
88 | ],
89 | );
90 | });
91 | break;
92 | case 1:
93 | MobPushNotifyMessage message =
94 | new MobPushNotifyMessage.fromJson(result);
95 | break;
96 | case 2:
97 | MobPushNotifyMessage message =
98 | new MobPushNotifyMessage.fromJson(result);
99 | break;
100 | }
101 | });
102 | }
103 |
104 | void _onError(dynamic event) {
105 | setState(() {
106 | print('>>>>>>>>>>>>>>>>>>>>>>>>>>>onError:' + event.toString());
107 | });
108 | }
109 |
110 | void _onAppNotifyPageTap() {
111 | setState(() {
112 | Navigator.push(context,
113 | new MaterialPageRoute(builder: (context) => new AppNotifyPage()));
114 | });
115 | }
116 |
117 | void _onNotifyPageTap() {
118 | setState(() {
119 | Navigator.push(context,
120 | new MaterialPageRoute(builder: (context) => new NotifyPage()));
121 | });
122 | }
123 |
124 | void _onTimingNotifyPageTap() {
125 | setState(() {
126 | Navigator.push(context,
127 | new MaterialPageRoute(builder: (context) => new TimingNotifyPage()));
128 | });
129 | }
130 |
131 | void _onLocalNotifyPageTap() {
132 | setState(() {
133 | Navigator.push(context,
134 | new MaterialPageRoute(builder: (context) => new LocalNotifyPage()));
135 | });
136 | }
137 |
138 | void _onOtherAPITap() {
139 | setState(() {
140 | Navigator.push(context,
141 | new MaterialPageRoute(builder: (context) => new OtherApiPage()));
142 | });
143 | }
144 |
145 | Future initPlatformState() async {
146 | String sdkVersion;
147 | try {
148 | sdkVersion = await MobpushPlugin.getSDKVersion();
149 | } on PlatformException {
150 | sdkVersion = 'Failed to get platform version.';
151 | }
152 | try {
153 | Future.delayed(Duration(milliseconds: 500),(){
154 | MobpushPlugin.getRegistrationId().then((Map ridMap) {
155 | print(ridMap);
156 | setState(() {
157 | _registrationId = ridMap['res'].toString();
158 | print('------>#### registrationId: ' + _registrationId);
159 | });
160 | });
161 | });
162 |
163 | } on PlatformException {
164 | _registrationId = 'Failed to get registrationId.';
165 | }
166 |
167 | // If the widget was removed from the tree while the asynchronous platform
168 | // message was in flight, we want to discard the reply rather than calling
169 | // setState to update our non-existent appearance.
170 | if (!mounted) return;
171 |
172 | setState(() {
173 | _sdkVersion = sdkVersion;
174 | });
175 | }
176 |
177 | // 复制到剪切板
178 | void _onCopyButtonClicked() {
179 | // 写入剪切板
180 | Clipboard.setData(ClipboardData(text: _registrationId));
181 | // 验证是否写入成功
182 | Clipboard.getData(Clipboard.kTextPlain).then((data) {
183 | if (data != null) {
184 | String? text = data.text;
185 | print('------>#### copyed registrationId: $text');
186 | if (text == _registrationId) {
187 | showDialog(
188 | context: context,
189 | builder: (context) {
190 | return AlertDialog(
191 | title: Text("恭喜🎉"),
192 | content: Container(
193 | margin: EdgeInsets.only(top: 10, bottom: 30),
194 | child: Text('复制成功!'),
195 | ),
196 | actions: [
197 | new TextButton(onPressed: () {
198 | Navigator.pop(context);
199 | }, child: Text("OK"))
200 | ],
201 | );
202 | }
203 | );
204 | }
205 | }
206 | });
207 | }
208 |
209 | @override
210 | Widget build(BuildContext context) {
211 | return MaterialApp(
212 | home: Scaffold(
213 | appBar: AppBar(
214 | title: const Text('MobPushPlugin Demo'),
215 | ),
216 | body: Column(
217 | children: [
218 | Expanded(
219 | child: Row(
220 | children: [
221 | Expanded(
222 | child: ClickContainer(
223 | content: 'App内推送',
224 | res: 'assets/images/ic_item_app_nitify.png',
225 | left: 15.0,
226 | top: 15.0,
227 | right: 7.5,
228 | bottom: 7.5,
229 | onTap: _onAppNotifyPageTap,
230 | ),
231 | ),
232 | Expanded(
233 | child: ClickContainer(
234 | content: '通知',
235 | res: 'assets/images/ic_item_notify.png',
236 | left: 7.5,
237 | top: 15.0,
238 | right: 15.0,
239 | bottom: 7.5,
240 | onTap: _onNotifyPageTap,
241 | ),
242 | ),
243 | ],
244 | ),
245 | ),
246 | Expanded(
247 | child: Row(
248 | children: [
249 | Expanded(
250 | child: ClickContainer(
251 | content: '定时推送',
252 | res: 'assets/images/ic_item_timing.png',
253 | left: 15.0,
254 | top: 7.5,
255 | right: 7.5,
256 | bottom: 7.5,
257 | onTap: _onTimingNotifyPageTap,
258 | ),
259 | ),
260 | Expanded(
261 | child: ClickContainer(
262 | content: '本地通知',
263 | res: 'assets/images/ic_item_local.png',
264 | left: 7.5,
265 | top: 7.5,
266 | right: 15.0,
267 | bottom: 7.5,
268 | onTap: _onLocalNotifyPageTap,
269 | ),
270 | ),
271 | ],
272 | ),
273 | ),
274 | Expanded(
275 | child: Row(
276 | children: [
277 | Expanded(
278 | child: ClickContainer(
279 | content: '其他API接口',
280 | res: 'assets/images/ic_item_media.png',
281 | left: 15.0,
282 | top: 7.5,
283 | right: 15.0,
284 | bottom: 7.5,
285 | onTap: _onOtherAPITap,
286 | ),
287 | ),
288 | ],
289 | ),
290 | ),
291 | Container(
292 | margin: EdgeInsets.only(left: 15.0, right: 15.0, bottom: 15.0),
293 | height: 60,
294 | child: Row(
295 | crossAxisAlignment: CrossAxisAlignment.start,
296 | children: [
297 | Text(
298 | 'SDK Version: $_sdkVersion\nRegistrationId: $_registrationId',
299 | style: TextStyle(fontSize: 12),
300 | ),
301 | ElevatedButton(
302 | child: Text('复制'),
303 | onPressed: _onCopyButtonClicked,
304 | )
305 | // RaisedButton(
306 | // child: Text('复制'),
307 | // onPressed: _onCopyButtonClicked,
308 | // ),
309 | ],
310 | ),
311 | ),
312 | ],
313 | ),
314 | ),
315 | );
316 | }
317 | }
318 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/lib/notify_page.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 | import 'package:mobpush_plugin/mobpush_plugin.dart';
4 |
5 | class NotifyPage extends StatefulWidget {
6 | @override
7 | _NotifyPageState createState() {
8 | return new _NotifyPageState();
9 | }
10 | }
11 |
12 | class _NotifyPageState extends State {
13 | TextEditingController _controller = new TextEditingController();
14 |
15 | void _send() async {
16 | if (_controller.text.isNotEmpty) {
17 | //发送消息类型为1的通知消息,推送内容时输入框输入的内容,延迟推送时间为0(立即推送),附加数据为空
18 | MobpushPlugin.send(1, _controller.text, 0, "").then((Map sendMap){
19 | String res = sendMap['res'];
20 | String error = sendMap['error'];
21 | print(">>>>>>>>>>>>>>>>>>>>>>>>>>> send -> res: $res error: $error");
22 | });
23 | }
24 | }
25 |
26 | @override
27 | Widget build(BuildContext context) {
28 | return Scaffold(
29 | appBar: AppBar(
30 | title: Text('通知测试'),
31 | iconTheme: IconThemeData(color: Colors.black),
32 | textTheme: TextTheme(headline6: TextStyle(color: Colors.black)),
33 | backgroundColor: Colors.white,
34 | centerTitle: true,
35 | ),
36 | body: Container(
37 | margin: EdgeInsets.all(15.0),
38 | child: Column(
39 | crossAxisAlignment: CrossAxisAlignment.start,
40 | children: [
41 | Text(
42 | "点击测试按钮后,你将收到一条测试通知",
43 | textAlign: TextAlign.left,
44 | ),
45 | Container(
46 | margin: EdgeInsets.only(top: 10, bottom: 30),
47 | child: TextField(
48 | maxLines: 5,
49 | maxLength: 35,
50 | decoration: InputDecoration(
51 | hintText: "填写推送内容(不超过35个字)",
52 | contentPadding: EdgeInsets.all(10),
53 | border: OutlineInputBorder(
54 | borderRadius: BorderRadius.all(Radius.circular(5.0)),
55 | borderSide: BorderSide(
56 | color: Color(0xFFe1e1e1),
57 | width: 0.5,
58 | style: BorderStyle.solid
59 | )
60 | )
61 | ),
62 | controller: _controller,
63 | ),
64 | ),
65 | Row(
66 | children: [
67 | new Expanded(
68 | child: new ElevatedButton(
69 | child: Text(
70 | '点击测试',
71 | style: new TextStyle(color: Colors.white),
72 | ),
73 | onPressed: _send,
74 | ),
75 | // child: new RaisedButton(
76 | // padding: EdgeInsets.symmetric(vertical: 12),
77 | // color: Color(0xFFFF7D00),
78 | // child: Text(
79 | // '点击测试',
80 | // style: new TextStyle(color: Colors.white),
81 | // ),
82 | // onPressed: _send,
83 | // )
84 | ),
85 | ],
86 | ),
87 | ],
88 | ),
89 | )
90 | );
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/lib/timing_notify_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:mobpush_plugin/mobpush_plugin.dart';
3 |
4 | class TimingNotifyPage extends StatefulWidget {
5 | @override
6 | _TimingNotifyPageState createState() {
7 | return new _TimingNotifyPageState();
8 | }
9 | }
10 |
11 | class _TimingNotifyPageState extends State {
12 | TextEditingController _controller = new TextEditingController();
13 |
14 | @override
15 | void initState() {
16 | super.initState();
17 | // MobpushPlugin.addPushReceiver(_onEvent, _onError);
18 | }
19 |
20 | // void _onEvent(Object event) {
21 | // setState(() {
22 | // print('>>>>>>>>>>>>>>>>>>>>>>>>>>>setStateONEvent:' + event.toString());
23 | // });
24 | // }
25 |
26 | // void _onError(Object event) {
27 | // setState(() {
28 | // print('>>>>>>>>>>>>>>>>>>>>>>>>>>>setStateonError:' + event.toString());
29 | // });
30 | // }
31 |
32 | void _send() async {
33 | if (_controller.text.isNotEmpty) {
34 | //发送消息类型为3的自延迟推送通知消息,推送内容时输入框输入的内容,延迟推送时间为1分钟(1分钟后推送),附加数据为空
35 | MobpushPlugin.send(3, _controller.text, 1, "").then((Map sendMap){
36 | String res = sendMap['res'];
37 | String error = sendMap['error'];
38 | print(">>>>>>>>>>>>>>>>>>>>>>>>>>> send -> res: $res error: $error");
39 | });
40 | }
41 | }
42 |
43 | @override
44 | Widget build(BuildContext context) {
45 | return Scaffold(
46 | appBar: AppBar(
47 | title: Text('定时通知测试'),
48 | iconTheme: IconThemeData(color: Colors.black),
49 | textTheme: TextTheme(headline6: TextStyle(color: Colors.black)),
50 | backgroundColor: Colors.white,
51 | centerTitle: true,
52 | ),
53 | body: Container(
54 | margin: EdgeInsets.all(15.0),
55 | child: Column(
56 | crossAxisAlignment: CrossAxisAlignment.start,
57 | children: [
58 | Text(
59 | "点击测试按钮后,在你设定的时间到了时将收到一条测试通知",
60 | textAlign: TextAlign.left,
61 | ),
62 | Container(
63 | margin: EdgeInsets.only(top: 10, bottom: 30),
64 | child: TextField(
65 | maxLines: 5,
66 | maxLength: 35,
67 | decoration: InputDecoration(
68 | hintText: "填写推送内容(不超过35个字)",
69 | contentPadding: EdgeInsets.all(10),
70 | border: OutlineInputBorder(
71 | borderRadius: BorderRadius.all(Radius.circular(5.0)),
72 | borderSide: BorderSide(
73 | color: Color(0xFFe1e1e1),
74 | width: 0.5,
75 | style: BorderStyle.solid
76 | )
77 | )
78 | ),
79 | controller: _controller,
80 | ),
81 | ),
82 | Row(
83 | children: [
84 | new Expanded(
85 | child: new ElevatedButton(
86 | child: Text(
87 | '点击测试',
88 | style: new TextStyle(color: Colors.white),
89 | ),
90 | onPressed: _send,
91 | ),
92 | // child: new RaisedButton(
93 | // padding: EdgeInsets.symmetric(vertical: 12),
94 | // color: Color(0xFF29C18B),
95 | // child: Text(
96 | // '点击测试',
97 | // style: new TextStyle(color: Colors.white),
98 | // ),
99 | // onPressed: _send,
100 | // )
101 | ),
102 | ],
103 | ),
104 | ],
105 | ),
106 | )
107 | );
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | url: "https://pub.flutter-io.cn"
9 | source: hosted
10 | version: "2.8.2"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.flutter-io.cn"
16 | source: hosted
17 | version: "2.1.0"
18 | characters:
19 | dependency: transitive
20 | description:
21 | name: characters
22 | url: "https://pub.flutter-io.cn"
23 | source: hosted
24 | version: "1.2.0"
25 | charcode:
26 | dependency: transitive
27 | description:
28 | name: charcode
29 | url: "https://pub.flutter-io.cn"
30 | source: hosted
31 | version: "1.3.1"
32 | clock:
33 | dependency: transitive
34 | description:
35 | name: clock
36 | url: "https://pub.flutter-io.cn"
37 | source: hosted
38 | version: "1.1.0"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.flutter-io.cn"
44 | source: hosted
45 | version: "1.15.0"
46 | cupertino_icons:
47 | dependency: "direct main"
48 | description:
49 | name: cupertino_icons
50 | url: "https://pub.flutter-io.cn"
51 | source: hosted
52 | version: "0.1.3"
53 | fake_async:
54 | dependency: transitive
55 | description:
56 | name: fake_async
57 | url: "https://pub.flutter-io.cn"
58 | source: hosted
59 | version: "1.2.0"
60 | flutter:
61 | dependency: "direct main"
62 | description: flutter
63 | source: sdk
64 | version: "0.0.0"
65 | flutter_test:
66 | dependency: "direct dev"
67 | description: flutter
68 | source: sdk
69 | version: "0.0.0"
70 | matcher:
71 | dependency: transitive
72 | description:
73 | name: matcher
74 | url: "https://pub.flutter-io.cn"
75 | source: hosted
76 | version: "0.12.11"
77 | material_color_utilities:
78 | dependency: transitive
79 | description:
80 | name: material_color_utilities
81 | url: "https://pub.flutter-io.cn"
82 | source: hosted
83 | version: "0.1.3"
84 | meta:
85 | dependency: transitive
86 | description:
87 | name: meta
88 | url: "https://pub.flutter-io.cn"
89 | source: hosted
90 | version: "1.7.0"
91 | mobpush_plugin:
92 | dependency: "direct dev"
93 | description:
94 | path: ".."
95 | relative: true
96 | source: path
97 | version: "1.2.9"
98 | path:
99 | dependency: transitive
100 | description:
101 | name: path
102 | url: "https://pub.flutter-io.cn"
103 | source: hosted
104 | version: "1.8.0"
105 | sky_engine:
106 | dependency: transitive
107 | description: flutter
108 | source: sdk
109 | version: "0.0.99"
110 | source_span:
111 | dependency: transitive
112 | description:
113 | name: source_span
114 | url: "https://pub.flutter-io.cn"
115 | source: hosted
116 | version: "1.8.1"
117 | stack_trace:
118 | dependency: transitive
119 | description:
120 | name: stack_trace
121 | url: "https://pub.flutter-io.cn"
122 | source: hosted
123 | version: "1.10.0"
124 | stream_channel:
125 | dependency: transitive
126 | description:
127 | name: stream_channel
128 | url: "https://pub.flutter-io.cn"
129 | source: hosted
130 | version: "2.1.0"
131 | string_scanner:
132 | dependency: transitive
133 | description:
134 | name: string_scanner
135 | url: "https://pub.flutter-io.cn"
136 | source: hosted
137 | version: "1.1.0"
138 | term_glyph:
139 | dependency: transitive
140 | description:
141 | name: term_glyph
142 | url: "https://pub.flutter-io.cn"
143 | source: hosted
144 | version: "1.2.0"
145 | test_api:
146 | dependency: transitive
147 | description:
148 | name: test_api
149 | url: "https://pub.flutter-io.cn"
150 | source: hosted
151 | version: "0.4.8"
152 | typed_data:
153 | dependency: transitive
154 | description:
155 | name: typed_data
156 | url: "https://pub.flutter-io.cn"
157 | source: hosted
158 | version: "1.3.0"
159 | vector_math:
160 | dependency: transitive
161 | description:
162 | name: vector_math
163 | url: "https://pub.flutter-io.cn"
164 | source: hosted
165 | version: "2.1.1"
166 | sdks:
167 | dart: ">=2.14.0 <3.0.0"
168 | flutter: ">=1.12.0"
169 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: mobpush_plugin_example
2 | description: Demonstrates how to use the mobpush_plugin plugin.
3 | publish_to: 'none'
4 |
5 | environment:
6 | sdk: ">=2.12.0 <3.0.0"
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 |
12 | # The following adds the Cupertino Icons font to your application.
13 | # Use with the CupertinoIcons class for iOS style icons.
14 | cupertino_icons: ^0.1.2
15 |
16 | dev_dependencies:
17 | flutter_test:
18 | sdk: flutter
19 |
20 | mobpush_plugin:
21 | path: ../
22 |
23 | # For information on the generic Dart part of this file, see the
24 | # following page: https://dart.dev/tools/pub/pubspec
25 |
26 | flutter:
27 |
28 | # The following line ensures that the Material Icons font is
29 | # included with your application, so that you can use the icons in
30 | # the material Icons class.
31 | uses-material-design: true
32 |
33 | # To add assets to your application, add an assets section, like this:
34 | assets:
35 | - assets/images/ic_item_app_nitify.png
36 | - assets/images/ic_item_local.png
37 | - assets/images/ic_item_media.png
38 | - assets/images/ic_item_notify.png
39 | - assets/images/ic_item_open_act.png
40 | - assets/images/ic_item_timing.png
41 |
42 | # An image asset can refer to one or more resolution-specific "variants", see
43 | # https://flutter.dev/assets-and-images/#resolution-aware.
44 |
45 | # For details regarding adding assets from package dependencies, see
46 | # https://flutter.dev/assets-and-images/#from-packages
47 |
48 | # To add custom fonts to your application, add a fonts section here,
49 | # in this "flutter" section. Each entry in this list should have a
50 | # "family" key with the font family name, and a "fonts" key with a
51 | # list giving the asset and other descriptors for the font. For
52 | # example:
53 | # fonts:
54 | # - family: Schyler
55 | # fonts:
56 | # - asset: fonts/Schyler-Regular.ttf
57 | # - asset: fonts/Schyler-Italic.ttf
58 | # style: italic
59 | # - family: Trajan Pro
60 | # fonts:
61 | # - asset: fonts/TrajanPro.ttf
62 | # - asset: fonts/TrajanPro_Bold.ttf
63 | # weight: 700
64 | #
65 | # For details regarding fonts from package dependencies,
66 | # see https://flutter.dev/custom-fonts/#from-packages
67 |
--------------------------------------------------------------------------------
/mobpush_plugin/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:mobpush_plugin_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Verify Platform version', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(MyApp());
17 |
18 | // Verify that platform version is retrieved.
19 | expect(
20 | find.byWidgetPredicate(
21 | (Widget widget) => widget is Text &&
22 | widget.data!.startsWith('Running on:'),
23 | ),
24 | findsOneWidget,
25 | );
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/mobpush_plugin/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 |
--------------------------------------------------------------------------------
/mobpush_plugin/ios/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MobClub/MobPush-For-Flutter/97a371e4b6339a28204761051302876b2e624b1c/mobpush_plugin/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/mobpush_plugin/ios/Classes/MobpushPlugin.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | // 标准: 对外桥接类命名,项目xx + Plugin. 例: MobpushPlugin
4 | @interface MobpushPlugin : NSObject
5 | @end
6 |
--------------------------------------------------------------------------------
/mobpush_plugin/ios/Classes/MobpushPlugin.m:
--------------------------------------------------------------------------------
1 | #import "MobpushPlugin.h"
2 | #import
3 | #import
4 | #import
5 | #import
6 | #import
7 |
8 | @interface MobpushPlugin()
9 | // 是否是生产环境
10 | @property (nonatomic, assign) BOOL isPro;
11 | // 事件回调
12 | @property (nonatomic, copy) void (^callBack) (id _Nullable event);
13 |
14 | @property (nonatomic, strong) NSMutableArray *tmps;
15 |
16 | @end
17 |
18 | @implementation MobpushPlugin
19 |
20 | static NSString *const receiverStr = @"com.mob.mobpush.reciever";
21 |
22 | + (void)registerWithRegistrar:(NSObject*)registrar {
23 | // 标准: MethodChannel 统一命名:com.mob.项目xx.功能
24 | FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"com.mob.mobpush.methodChannel" binaryMessenger:[registrar messenger]];
25 | MobpushPlugin* instance = [[MobpushPlugin alloc] init];
26 | [registrar addMethodCallDelegate:instance channel:channel];
27 |
28 | FlutterEventChannel* e_channel = [FlutterEventChannel eventChannelWithName:receiverStr binaryMessenger:[registrar messenger]];
29 | [e_channel setStreamHandler:instance];
30 |
31 | [instance addObserver];
32 | }
33 |
34 | - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
35 | if ([@"getPlatformVersion" isEqualToString:call.method]) {
36 | result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
37 | }
38 | else if ([@"getSDKVersion" isEqualToString:call.method])
39 | {
40 | //TODO: SDK 添加获取版本号接口
41 | result([MobPush sdkVersion]);
42 | }
43 | else if ([@"getRegistrationId" isEqualToString:call.method]) {
44 | [MobPush getRegistrationID:^(NSString *registrationID, NSError *error) {
45 | if (error) {
46 | result(@{@"res": @"", @"error": error.localizedDescription});
47 | } else {
48 | result(@{@"res": registrationID, @"error": @""});
49 | }
50 | }];
51 | }
52 | else if ([@"stopPush" isEqualToString:call.method])
53 | {
54 | [MobPush stopPush];
55 | }
56 | else if ([@"restartPush" isEqualToString:call.method])
57 | {
58 | [MobPush restartPush];
59 | }
60 | else if ([@"isPushStopped" isEqualToString:call.method])
61 | {
62 | result(@([MobPush isPushStopped]));
63 | }
64 | else if ([@"setAlias" isEqualToString:call.method])
65 | {
66 | NSDictionary *arguments = (NSDictionary *)call.arguments;
67 | if (arguments && arguments[@"alias"] && [arguments[@"alias"] isKindOfClass:[NSString class]])
68 | {
69 | [MobPush setAlias:arguments[@"alias"] result:^(NSError *error) {
70 | NSString *errorStr = error ? error.localizedDescription : @"";
71 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
72 | }];
73 | }
74 | else
75 | {
76 | result(@{@"res": @"failed", @"error": @"Arguments Invaild."});
77 | }
78 | }
79 | else if ([@"getAlias" isEqualToString:call.method])
80 | {
81 | [MobPush getAliasWithResult:^(NSString *alias, NSError *error) {
82 | if (error) {
83 | result(@{@"res": @"", @"error": error.localizedDescription});
84 | } else {
85 | NSString *rstAlias = alias;
86 | if (!alias) {
87 | rstAlias = @"";
88 | }
89 | result(@{@"res": rstAlias, @"error": @""});
90 | }
91 | }];
92 | }
93 | else if ([@"deleteAlias" isEqualToString:call.method])
94 | {
95 | [MobPush deleteAlias:^(NSError *error) {
96 | NSString *errorStr = error ? error.localizedDescription : @"";
97 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
98 | }];
99 | }
100 | else if ([@"addTags" isEqualToString:call.method])
101 | {
102 | NSDictionary *arguments = (NSDictionary *)call.arguments;
103 | if (arguments && arguments[@"tags"]) {
104 | [MobPush addTags:arguments[@"tags"] result:^(NSError *error) {
105 | NSString *errorStr = error ? error.localizedDescription : @"";
106 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
107 | }];
108 | }
109 | else
110 | {
111 | result(@{@"res": @"failed", @"error": @"Arguments Invaild."});
112 | }
113 |
114 | }
115 | else if ([@"getTags" isEqualToString:call.method])
116 | {
117 | [MobPush getTagsWithResult:^(NSArray *tags, NSError *error) {
118 | if (error) {
119 | result(@{@"res": @"", @"error": error.localizedDescription});
120 | } else {
121 | result(@{@"res": tags, @"error": @""});
122 | }
123 | }];
124 | }
125 | else if ([@"deleteTags" isEqualToString:call.method])
126 | {
127 | NSDictionary *arguments = (NSDictionary *)call.arguments;
128 | if (arguments && arguments[@"tags"]) {
129 | [MobPush deleteTags:arguments[@"tags"] result:^(NSError *error) {
130 | NSString *errorStr = error ? error.localizedDescription : @"";
131 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
132 | }];
133 | }
134 | else
135 | {
136 | result(@{@"res": @"failed", @"error": @"Arguments Invaild."});
137 | }
138 | }
139 | else if ([@"cleanTags" isEqualToString:call.method])
140 | {
141 | [MobPush cleanAllTags:^(NSError *error) {
142 | NSString *errorStr = error ? error.localizedDescription : @"";
143 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
144 | }];
145 | }
146 | else if ([@"addLocalNotification" isEqualToString:call.method])
147 | {
148 | NSDictionary *arguments = (NSDictionary *)call.arguments;
149 | if (arguments && arguments[@"localNotification"])
150 | {
151 | NSString *localStr = arguments[@"localNotification"];
152 | NSDictionary *eventParams = [MOBFJson objectFromJSONString:localStr];
153 |
154 | NSString *identifier = nil;
155 |
156 | MPushNotification *noti = [[MPushNotification alloc] init];
157 | if (eventParams[@"title"] && ![eventParams[@"title"] isKindOfClass:[NSNull class]])
158 | {
159 | noti.title = eventParams[@"title"];
160 | }
161 | if (eventParams[@"content"] && ![eventParams[@"content"] isKindOfClass:[NSNull class]])
162 | {
163 | noti.body = eventParams[@"content"];
164 | }
165 | if (eventParams[@"sound"] && ![eventParams[@"sound"] isKindOfClass:[NSNull class]])
166 | {
167 | noti.sound = eventParams[@"sound"];
168 |
169 | }
170 | if (eventParams[@"badge"] && ![eventParams[@"badge"] isKindOfClass:[NSNull class]])
171 | {
172 | noti.badge = [eventParams[@"badge"] integerValue];
173 | }
174 | if (eventParams[@"subTitle"] && ![eventParams[@"subTitle"] isKindOfClass:[NSNull class]])
175 | {
176 | noti.subTitle = eventParams[@"subTitle"];
177 | }
178 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
179 | if (eventParams[@"extrasMap"] && ![eventParams[@"extrasMap"] isKindOfClass:[NSNull class]])
180 | {
181 | [userInfo addEntriesFromDictionary:eventParams[@"extrasMap"]];
182 |
183 | }
184 | if (eventParams[@"messageId"] && ![eventParams[@"messageId"] isKindOfClass:[NSNull class]])
185 | {
186 | NSString *messageId = eventParams[@"messageId"];
187 | userInfo[@"messageId"] = messageId;
188 | identifier = messageId;
189 | }
190 |
191 | noti.userInfo = [userInfo copy];
192 |
193 | if (eventParams[@"identifier"] && ![eventParams[@"identifier"] isKindOfClass:[NSNull class]])
194 | {
195 | identifier = eventParams[@"messageId"];
196 | }
197 |
198 | MPushNotificationTrigger *trigger = [MPushNotificationTrigger new];
199 |
200 | if (eventParams[@"timestamp"] && ![eventParams[@"timestamp"] isKindOfClass:[NSNull class]])
201 | {
202 | double timeStamp = [eventParams[@"timestamp"] doubleValue];
203 | if (timeStamp > 0)
204 | {
205 | NSDate *currentDate = [NSDate dateWithTimeIntervalSinceNow:0];
206 | NSTimeInterval nowtime = [currentDate timeIntervalSince1970] * 1000;
207 | NSTimeInterval tasktimeInterval = nowtime + (NSTimeInterval)timeStamp;
208 |
209 | if (@available(iOS 10.0, *))
210 | {
211 | trigger.timeInterval = timeStamp;
212 | }
213 | else
214 | {
215 | trigger.fireDate = [NSDate dateWithTimeIntervalSince1970:tasktimeInterval];
216 | }
217 | }
218 | }
219 |
220 | MPushNotificationRequest *request = [MPushNotificationRequest new];
221 | request.requestIdentifier = identifier;
222 | request.content = noti;
223 | request.trigger = trigger;
224 |
225 | [MobPush addLocalNotification:request result:^(id res, NSError *error) {
226 | NSString *errorStr = error ? error.localizedDescription : @"";
227 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
228 | }];
229 | }
230 | }
231 | else if ([@"bindPhoneNum" isEqualToString:call.method])
232 | {
233 | NSDictionary *arguments = (NSDictionary *)call.arguments;
234 | if (arguments && arguments[@"phoneNum"])
235 | {
236 | [MobPush bindPhoneNum:arguments[@"phoneNum"] result:^(NSError *error) {
237 | NSString *errorStr = error ? error.localizedDescription : @"";
238 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr});
239 | }];
240 | }
241 | else
242 | {
243 | result(@{@"res": @"failed", @"error": @"Arguments Invaild."});
244 | }
245 | }
246 | else if ([@"send" isEqualToString:call.method])
247 | {
248 | NSDictionary *arguments = (NSDictionary *)call.arguments;
249 | if (arguments) {
250 | NSInteger type = [arguments[@"type"] integerValue];
251 | NSString *content = arguments[@"content"];
252 | NSNumber *space = arguments[@"space"];
253 | NSDictionary *extras = (NSDictionary *)arguments[@"extrasMap"];
254 | NSString *sound = arguments[@"sound"];
255 | NSString *coverId = arguments[@"coverId"];
256 | [MobPush sendMessageWithMessageType:type
257 | content:content
258 | space:space
259 | sound:sound
260 | isProductionEnvironment:_isPro
261 | extras:extras
262 | linkScheme:nil
263 | linkData:nil
264 | coverId:coverId
265 | result:^(NSString *workId, NSError *error) {
266 | NSString *errorStr = error ? error.localizedDescription : @"";
267 | NSString *workIdStr = workId?:@"";
268 | result(@{@"res": error ? @"failed": @"success", @"error": errorStr, @"workId" : workIdStr});
269 | }];
270 | }
271 | else
272 | {
273 | result(@{@"res": @"failed", @"error": @"Arguments Invaild."});
274 | }
275 | }
276 | else if ([@"setAPNsForProduction" isEqualToString:call.method])
277 | {
278 | NSDictionary *arguments = (NSDictionary *)call.arguments;
279 | _isPro = [arguments[@"isPro"] boolValue];
280 | [MobPush setAPNsForProduction:_isPro];
281 | }
282 | else if ([@"setBadge" isEqualToString:call.method])
283 | {
284 | NSDictionary *arguments = (NSDictionary *)call.arguments;
285 | NSInteger badge = [arguments[@"badge"] integerValue];
286 | UIApplication.sharedApplication.applicationIconBadgeNumber = badge;
287 | [MobPush setBadge:badge];
288 | }
289 | else if ([@"clearBadge" isEqualToString:call.method])
290 | {
291 | [MobPush clearBadge];
292 | }
293 | else if ([@"setAPNsShowForegroundType" isEqualToString:call.method])
294 | {
295 | NSDictionary *arguments = (NSDictionary *)call.arguments;
296 | NSInteger type = [arguments[@"type"] integerValue];
297 | [MobPush setAPNsShowForegroundType:type];
298 | }
299 | else if ([@"setCustomNotification" isEqualToString:call.method])
300 | {
301 | MPushNotificationConfiguration *config = [[MPushNotificationConfiguration alloc] init];
302 | config.types = MPushAuthorizationOptionsSound | MPushAuthorizationOptionsBadge | MPushAuthorizationOptionsAlert;
303 | [[MOBFDataService sharedInstance] setCacheData:config
304 | forKey:@"MPushNotificationConfiguration"
305 | domain:@"MOBPUSH_FLUTTER_PLUGIN"];
306 | [MobPush setupNotification:config];
307 | }
308 | else if ([@"updatePrivacyPermissionStatus" isEqualToString:call.method])
309 | {
310 | NSDictionary *arguments = (NSDictionary *)call.arguments;
311 | NSInteger status = [arguments[@"status"] integerValue];
312 | [MobSDK uploadPrivacyPermissionStatus:status onResult:^(BOOL success) {
313 | result(@(success));
314 | }];
315 | }
316 | else if ([@"setRegionId" isEqualToString:call.method]) {
317 | NSDictionary *arguments = (NSDictionary *)call.arguments;
318 | int regionId = [arguments[@"regionId"] intValue];
319 | [MobPush setRegionID:regionId];
320 | }
321 | else if ([@"registerApp" isEqualToString:call.method]) {
322 | NSDictionary *arguments = (NSDictionary *)call.arguments;
323 | NSString *appKey = arguments[@"appKey"];
324 | NSString *appSecret = arguments[@"appSecret"];
325 | [MobSDK registerAppKey:appKey appSecret:appSecret];
326 | }
327 | else
328 | {
329 | result(FlutterMethodNotImplemented);
330 | }
331 | }
332 |
333 | #pragma mark - FlutterStreamHandler Protocol
334 |
335 | - (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)events
336 | {
337 | self.callBack = events;
338 | return nil;
339 | }
340 |
341 | - (FlutterError * _Nullable)onCancelWithArguments:(id _Nullable)arguments
342 | {
343 | return nil;
344 | }
345 |
346 | #pragma mark - 监听消息通知
347 |
348 | - (void)addObserver
349 | {
350 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];
351 | MPushNotificationConfiguration *config = [[MOBFDataService sharedInstance] cacheDataForKey:@"MPushNotificationConfiguration" domain:@"MOBPUSH_FLUTTER_PLUGIN"];
352 | if (config && [config isKindOfClass:MPushNotificationConfiguration.class])
353 | {
354 | [MobPush setupNotification:config];
355 | }
356 | }
357 |
358 | - (void)didReceiveMessage:(NSNotification *)notification
359 | {
360 | // NSLog(@"flutter: ================ didReceiveMessage =========================");
361 | if ([notification.object isKindOfClass:[MPushMessage class]])
362 | {
363 | MPushMessage *message = (MPushMessage *)notification.object;
364 | NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
365 | NSMutableDictionary *reslut = [NSMutableDictionary dictionary];
366 | switch (message.messageType)
367 | {
368 | case MPushMessageTypeCustom:
369 | {// 自定义消息
370 | [resultDict setObject:@(0) forKey:@"action"];
371 | if (message.notification.userInfo)
372 | {
373 | [reslut setObject:message.notification.userInfo forKey:@"extrasMap"];
374 | }
375 | if (message.notification.body)
376 | {
377 | [reslut setObject:message.notification.body forKey:@"content"];
378 | }
379 | if (message.messageID)
380 | {
381 | [reslut setObject:message.messageID forKey:@"messageId"];
382 | }
383 | [reslut addEntriesFromDictionary:message.notification.convertDictionary];
384 | }
385 | break;
386 | case MPushMessageTypeAPNs:
387 | {// APNs 回调
388 |
389 | if (message.notification.userInfo)
390 | {
391 | [reslut setObject:message.notification.userInfo forKey:@"extrasMap"];
392 | }
393 | if (message.notification.body)
394 | {
395 | [reslut setObject:message.notification.body forKey:@"content"];
396 | }
397 | if (message.messageID)
398 | {
399 | [reslut setObject:message.messageID forKey:@"messageId"];
400 | }
401 | [reslut addEntriesFromDictionary:message.notification.convertDictionary];
402 |
403 | [resultDict setObject:@(1) forKey:@"action"];
404 | }
405 | break;
406 | case MPushMessageTypeLocal:
407 | { // 本地通知回调
408 | if (message.notification.userInfo)
409 | {
410 | [reslut setObject:message.notification.userInfo forKey:@"extrasMap"];
411 | }
412 | if (message.notification.body)
413 | {
414 | [reslut setObject:message.notification.body forKey:@"content"];
415 | }
416 | if (message.messageID)
417 | {
418 | [reslut setObject:message.messageID forKey:@"messageId"];
419 | }
420 | [reslut addEntriesFromDictionary:message.notification.convertDictionary];
421 |
422 | [resultDict setObject:@(1) forKey:@"action"];
423 | }
424 | break;
425 |
426 | case MPushMessageTypeClicked:
427 | {
428 |
429 | if (message.notification.userInfo)
430 | {
431 | [reslut setObject:message.notification.userInfo forKey:@"extrasMap"];
432 | }
433 | if (message.notification.body)
434 | {
435 | [reslut setObject:message.notification.body forKey:@"content"];
436 | }
437 | if (message.messageID)
438 | {
439 | [reslut setObject:message.messageID forKey:@"messageId"];
440 | }
441 | [reslut addEntriesFromDictionary:message.notification.convertDictionary];
442 |
443 | [resultDict setObject:@(2) forKey:@"action"];
444 |
445 | }
446 | break;
447 |
448 | default:
449 | break;
450 | }
451 | if (reslut.count > 0)
452 | {
453 | [resultDict setObject:reslut forKey:@"result"];
454 | }
455 | // 回调结果
456 | NSString *resultDictStr = [MOBFJson jsonStringFromObject:resultDict];
457 |
458 | if (self.callBack)
459 | {
460 | self.callBack(resultDictStr);
461 | }
462 | else
463 | {
464 | if(_tmps)
465 | {
466 | [_tmps addObject:resultDictStr];
467 | }
468 | else
469 | {
470 | _tmps = @[resultDictStr].mutableCopy;
471 | }
472 | }
473 |
474 | }
475 | }
476 |
477 | - (void)setCallBack:(void (^)(id _Nullable))callBack
478 | {
479 | _callBack = callBack;
480 |
481 | if (_callBack && _tmps.count)
482 | {
483 | for (NSString *obj in _tmps) {
484 | _callBack(obj);
485 | }
486 | }
487 | }
488 |
489 |
490 | - (void)dealloc
491 | {
492 | [[NSNotificationCenter defaultCenter] removeObserver:self];
493 | }
494 |
495 | @end
496 |
--------------------------------------------------------------------------------
/mobpush_plugin/ios/mobpush_plugin.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
3 | #
4 | Pod::Spec.new do |s|
5 | # 标准: 名字需要和文件名字保持一致,不带后缀
6 | s.name = 'mobpush_plugin'
7 | # 标准: ios目录有改动,需要更新版本号
8 | s.version = '1.3.0'
9 | # 标准: 需要添加内容
10 | s.summary = 'mobpush 是一款推送SDK.'
11 | # 标准: 需要添加内容
12 | s.description = <<-DESC
13 | A new flutter plugin project.
14 | DESC
15 | # 标准: 添加官网对应插件项目的首页
16 | s.homepage = 'http://www.mob.com/mobService/mobpush'
17 | # 标准: 固定为 { :file => '../LICENSE' }
18 | s.license = { :file => '../LICENSE' }
19 | # 标准: 固定为 { 'Mob' => 'mobproducts@mob.com' }
20 | s.author = { 'Mob' => 'mobproducts@mob.com' }
21 | # 标准: 固定为 { :path => '.' }
22 | s.source = { :path => '.' }
23 | # 标准: 固定为 'Classes/**/*'
24 | s.source_files = 'Classes/**/*'
25 | # 标准: 固定为'Classes/**/*.h'
26 | s.public_header_files = 'Classes/**/*.h'
27 | # 标准: 固定为'Flutter'
28 | s.dependency 'Flutter'
29 | # 标准: 根据具体需要引入库,如 'mob_pushsdk'
30 | s.dependency 'mob_pushsdk'
31 | # 标准: 固定为true
32 | s.static_framework = true
33 |
34 | # 标准: 固定为 '8.0'
35 | s.ios.deployment_target = '9.0'
36 | end
37 |
38 |
--------------------------------------------------------------------------------
/mobpush_plugin/lib/mobpush_custom_message.dart:
--------------------------------------------------------------------------------
1 |
2 | class MobPushCustomMessage {
3 | String content;
4 | String? messageId;
5 | int? timestamp;
6 | Map? extrasMap;
7 |
8 | MobPushCustomMessage(this.content, this.messageId, this.timestamp, this.extrasMap);
9 |
10 | factory MobPushCustomMessage.fromJson(Map json) {
11 | return MobPushCustomMessage(json['content'], json['messageId'], json['timeStamp'], json['extrasMap']);
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/mobpush_plugin/lib/mobpush_local_notification.dart:
--------------------------------------------------------------------------------
1 | import 'mobpush_notify_message.dart';
2 |
3 | class MobPushLocalNotification extends MobPushNotifyMessage {
4 | int? notificationId;
5 |
6 | MobPushLocalNotification(
7 | {this.notificationId,
8 | title,
9 | content,
10 | timestamp,
11 | subTitle,
12 | sound,
13 | badge,
14 | styleContent,
15 | messageId,
16 | inboxStyleContent,
17 | style,
18 | channel,
19 | extrasMap,
20 | voice,
21 | shake,
22 | light})
23 | : super(
24 | title: title,
25 | content: content,
26 | timestamp: timestamp,
27 | subTitle: subTitle,
28 | sound: sound,
29 | badge: badge,
30 | styleContent: styleContent,
31 | messageId: messageId,
32 | inboxStyleContent: inboxStyleContent,
33 | style: style,
34 | channel: channel,
35 | extrasMap: extrasMap,
36 | voice: voice,
37 | shake: shake,
38 | light: light);
39 |
40 | Map toJson() => {
41 | 'notificationId': notificationId,
42 | 'title': title,
43 | 'content': content,
44 | 'messageId': messageId,
45 | 'inboxStyleContent': inboxStyleContent,
46 | 'timestamp': timestamp,
47 | 'style': style,
48 | 'channel': channel,
49 | 'extrasMap': extrasMap,
50 | 'voice': voice,
51 | 'shake': shake,
52 | 'styleContent': styleContent,
53 | 'light': light,
54 | 'badge': badge,
55 | 'sound': sound,
56 | 'subTitle': subTitle
57 | };
58 | }
59 |
--------------------------------------------------------------------------------
/mobpush_plugin/lib/mobpush_notify_message.dart:
--------------------------------------------------------------------------------
1 |
2 | class MobPushNotifyMessage {
3 | // iOS Properties
4 | String? subTitle;
5 | String? sound;
6 | int? badge;
7 | // Android Properties
8 | String? styleContent;
9 | String? messageId;
10 | List? inboxStyleContent;
11 | int? style;
12 | int? channel;
13 | Map? extrasMap;
14 | bool? voice;
15 | bool? shake;
16 | bool? light;
17 | String? title;
18 | String content;
19 | int? timestamp;
20 |
21 | MobPushNotifyMessage({this.title, required this.content, this.timestamp, this.subTitle, this.sound, this.badge, this.styleContent, required this.messageId, this.inboxStyleContent, this.style, this.channel, this.extrasMap, this.voice, this.shake, this.light});
22 |
23 | factory MobPushNotifyMessage.fromJson(Map json) {
24 | return MobPushNotifyMessage(
25 | title: json['title'],
26 | content: json['content'],
27 | messageId: json['messageId'],
28 | timestamp: json['timestamp'],
29 | style: json['style'],
30 | channel: json['channel'],
31 | voice: json['voice'],
32 | shake: json['shake'],
33 | extrasMap: json['extrasMap'],
34 | inboxStyleContent: json['inboxStyleContent'],
35 | styleContent: json['styleContent'],
36 | light: json['light'],
37 | badge: json['badge'],
38 | sound: json['sound'],
39 | subTitle: json['subTitle']);
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/mobpush_plugin/lib/mobpush_plugin.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:convert';
3 | import 'package:flutter/services.dart';
4 | import 'mobpush_local_notification.dart';
5 |
6 | typedef void EventHandler(dynamic event);
7 |
8 | class MobpushPlugin {
9 | // 标准: MethodChannel 统一命名:com.mob.项目xx.功能
10 | static const MethodChannel _channel = const MethodChannel('com.mob.mobpush.methodChannel');
11 | static EventChannel _channelReciever = const EventChannel('com.mob.mobpush.reciever');
12 |
13 | static Future get getPlatformVersion async {
14 | return await _channel.invokeMethod('getPlatformVersion');
15 | }
16 |
17 | /*
18 | *上传隐私协议.
19 | */
20 | static Future updatePrivacyPermissionStatus(bool agree) async {
21 | return await _channel.invokeMethod('updatePrivacyPermissionStatus', {'status': agree});
22 | }
23 |
24 | /*
25 | *获取SDK版本号.
26 | */
27 | static Future getSDKVersion() async {
28 | return await _channel.invokeMethod('getSDKVersion');
29 | }
30 |
31 | /*
32 | *获取regId.
33 | */
34 | static Future