百度云推送信息至 cordova应用
1.百度上创建开发者帐号
http://developer.baidu.com/
2.登录后进入“开发者服务管理”
3.创建应用
APP KEY 需要记下来,cordova 程序中需要使用它。
4.创建cordova 应用
D:\app\android_workspace>cordova create TestPush com.app.push TestPush Creating a new cordova project with name "TestPush" and id "com.app.push" at location "D:\app\android_workspace\TestPush"
5. 添加应用平台
D:\app\android_workspace>cd TestPush D:\app\android_workspace\TestPush>cordova platform add android Adding android project... Creating Cordova project for the Android platform: Path: platforms\android Package: com.app.push Name: TestPush Android target: android-21 Copying template files... Project successfully created.
6.添加百度云消息推送插件:
D:\app\android_workspace\TestPush>cordova plugin add com.cmpsoft.mobile.plugin.p ushnotification Fetching plugin "com.cmpsoft.mobile.plugin.pushnotification" via plugin registry Installing "com.cmpsoft.mobile.plugin.pushnotification" for android
7.修改 项目根下 www/index.html ,添加如下:
<script type="text/javascript" > function onDeviceReady() { fastgoPushNotification.init("KerdAAt9KahoeC5BnVjtbiNX");//参数为百度云中创建应用的APP KEY } document.addEventListener('deviceready',onDeviceReady); </script>
8.启动应用测试
D:\app\android_workspace\TestPush>cordova run android //使用android 手机测试,需要安装手机驱动,可以使用 adb shell 命令查看能否成功连接到手机 //省略N多输出 BUILD SUCCESSFUL Total time: 43 seconds Built the following apk(s): D:\app\android_workspace\TestPush\platforms\android\ant-build\MainActivity-d ebug.apk Using apk: D:\app\android_workspace\TestPush\platforms\android\ant-build\MainAct ivity-debug.apk Installing app on device... Launching application... LAUNCH SUCCESS
这时应用已经启动了。
9.使用百度云推送消息
进入后选择创建通知:
点击发送。
10.手机端接收到消息
相关推荐
绿豆饼 2020-07-28
malonely 2020-07-20
liujia 2020-06-02
chenxiangpeng 2020-04-30
kfq00 2020-04-10
malonely 2020-01-19
liujia 2019-12-27
chunianyo 2019-12-14
kfq00 2014-06-30
朱莉的乔夫 2015-03-26
kehongyong 2015-05-12
Go贝壳 2015-06-14
莫封洛 2015-06-13
shichong 2015-05-14
MonkeyKingBi 2015-10-30
百度通告 2015-12-26
welldum 2019-09-07
inyiyi 2018-09-05