温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android 极光推送基本步骤

发布时间:2020-09-14 00:05:19 来源:网络 阅读:990 作者:niceheart 栏目:移动开发

 这两天在研究推送的问题,后来确定了用极光推送,本人将整个过程整理一下:

 1、到极光官网注册账号:https://www.jpush.cn/

 2、创建应用,按照要求填写你的应用名称,包名提交

 3、下载案例来玩玩,一般情况测试是能收到信息的

 4、集成到自己的项目中,按照官网的集成http://docs.jpush.cn/pages/viewpage.action?pageId=557214

 5、集成时将注意的要点,官网上也有说,但是我再强调一下,因为本人在集成的时候没注意导致推送失败:

 (1)注意两个权限的包名填写,我们有可能直接用案例上的拷贝到自己的manifest中时没有替换掉包名,切记,要替换成自己的项目的包名(红色部分):

 

   <permission android:name="com.xxx.permission.JPUSH_MESSAGE"

       android:protectionLevel="signature" />


   <!-- Required  一些系统要求的权限,如访问网络等-->

   <uses-permission android:name="com.xxx.permission.JPUSH_MESSAGE" />

 (2)核心服务处的包名:

      <!-- Required SDK核心功能-->

       <receiver

           android:name="cn.jpush.android.service.PushReceiver"

           android:enabled="true" >

            <intent-filter android:priority="1000">

               <action       android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />  

<!--Required  显示通知栏 -->

               <category android:name="com.xxx" />

           </intent-filter>

           <intent-filter>

               <action android:name="android.intent.action.USER_PRESENT" />

               <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />

           </intent-filter>

            <!-- Optional -->

           <intent-filter>

               <action android:name="android.intent.action.PACKAGE_ADDED" />

               <action android:name="android.intent.action.PACKAGE_REMOVED" />

               <data android:scheme="package" />

           </intent-filter>


       </receiver>

   (3)按照官网的集成步骤去做就可以了。

 6、要想自己打开信息查看,自己要写一个广播接收信息,判断这句,将bundle带到指定的Activity显示即可:

   Bundle bundle = intent.getExtras();  

 if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {

    JPushInterface.reportNotificationOpened(context,   bundle.getString(JPushInterface.EXTRA_MSG_ID));


    //打开自定义的Activity

   Intent i = new Intent(context, JPushDetailActivity.class);

   i.putExtras(bundle);

   i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

   context.startActivity(i);}

  经过以上的步骤,android客户端基本OK,后续IOS的步骤和服务端步骤……

   

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI