Home > php教程 > php手册 > body text

[APICloud教程] 极光推送(ajpush)demo

WBOY
Release: 2016-06-07 11:37:11
Original
1934 people have browsed it

[APICloud教程] 极光推送(ajpush)demo
注意:使用极光推送,必须到官网编译正式版本并且勾选极光推送模块,apploader中目前暂时未包含极光推送模块,所以无法在apploader中直接使用,通常会报类似:cannot call method 'init' of undefind at xxx.html 的错误。

官方版极光推送模块各个api的简单代码示例。

使用前请将config中的appkey换成你的app的。

使用步骤:

1、在APICloud云端新建app并获取应用包名:预览-》端开发-》证书-》获取ios和android相应的包名(ID)。

2、登录极光推送官网http://www.jpush.cn,注册成为开发者,然后进入控制台,新建应用,并将在APICloud网站获取的应用包名填入对应位置,完成,在“应用信息”界面即可获取该到appKey,将该appKey复制,并写入本demo中的config文件中的app_key字段

3、将代码提交到1中新建的app中,编译,安装,使用

4、登录极光推送官网,进入控制台,选择2中新建的应用,开始发消息/通知等。


注意:监听状态栏通知被点击的函数尽量在index页面书写:
index.html:

var jpush = null;
apiready = function(){
jpush = api.require('ajpush');
api.addEventListener({name:'appintent'}, function(ret,err) {
alert('通知被点击,收到数据:\n' + JSON.stringify(ret));//监听通知被点击后收到的数据
})
api.addEventListener({name:'pause'}, function(ret,err) {
onPause();//监听应用进入后台,通知jpush暂停事件
})

api.addEventListener({name:'resume'}, function(ret,err) {
onResume();//监听应用恢复到前台,通知jpush恢复事件
})
}

//统计-app恢复
function onResume(){
jpush.onResume();
console.log('JPush onResume');
}

//统计-app暂停
function onPause(){
jpush.onPause();
console.log('JPush onPause');
}

原文链接:http://community.apicloud.com/bbs/forum.php?mod=viewthread&tid=1841

附件 AJPush_Demo.zip ( 15.19 KB 下载:106 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!