Use of Aurora Push for Android Development

Aurora push official website

  1. First, you need to register an account on the Jiguang Push official website and log in
  2. Enter the application management interface and create an application
    Note : The application name can be arbitrary, but the package name needs to be the same as the package name in the project. After the creation is completed, an appkey will be obtained which needs to be used when writing code.
  3. After the creation is completed, download the official demo pushed by Jiguang
  4. Add the files under the lib folder in the official demo to the lib folder in the target project
    lib file
    Note
    : After adding the jar file, you need to add dependencies. There are two methods: 1. "File"->"Project Structure"- >"Dependencies"->"+"->"jar-dependency"->Find the added jar
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="grooter.mobile"   
    android:versionCode="312"
    android:versionName="3.1.2"
    >
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" />

    <!-- Required -->
    <permission
        android:name="grooter.mobile.permission.JPUSH_MESSAGE"
        android:protectionLevel="signature" />

    <!-- Required  一些系统要求的权限,如访问网络等-->
    <uses-permission android:name="grooter.mobile.permission.JPUSH_MESSAGE" />
    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!-- Optional for location -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_TASKS" />

    <application
        android:icon="@drawable/ic_launcher"
        android:allowBackup="false"
        android:label="@string/app_name"
        android:name="com.example.jpushdemo.ExampleApplication">

        <!-- For test only 测试的主程序-->
        <activity
            android:name="com.example.jpushdemo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

       <!-- For test only 测试高级功能 -->

        <!-- For test only 测试设置 -->
       <activity android:name="com.example.jpushdemo.SettingActivity" android:label="@string/app_name"></activity>

        <!-- For test only 测试状态通知栏,需要打开的Activity -->
        <activity android:name="com.example.jpushdemo.TestActivity" android:exported="false">
            <intent-filter>
                <action android:name="jpush.testAction" />
                <category android:name="jpush.testCategory" />
            </intent-filter>
        </activity>

        <!-- Rich push 核心功能 since 2.0.6-->
        <activity
            android:name="cn.jpush.android.ui.PopWinActivity"
            android:theme="@style/MyDialogStyle"
            android:exported="false">
        </activity>

        <!-- Required SDK核心功能-->
        <activity
            android:name="cn.jpush.android.ui.PushActivity"
            android:configChanges="orientation|keyboardHidden"
            android:theme="@android:style/Theme.NoTitleBar"
            android:exported="false">
            <intent-filter>
                <action android:name="cn.jpush.android.ui.PushActivity" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="grooter.mobile" />
            </intent-filter>
        </activity>

        <!-- Required SDK 核心功能-->
        <!-- 可配置android:process参数将PushService放在其他进程中 -->
        <service
            android:name="cn.jpush.android.service.PushService"
            android:process=":mult"
            android:exported="false">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.REGISTER" />
                <action android:name="cn.jpush.android.intent.REPORT" />
                <action android:name="cn.jpush.android.intent.PushService" />
                <action android:name="cn.jpush.android.intent.PUSH_TIME" />
            </intent-filter>

        <!-- since 3.0.9 Required SDK 核心功能-->
        <provider
            android:authorities="grooter.mobile.DataProvider"
            android:name="cn.jpush.android.service.DataProvider"
            android:exported="false"
        />

        <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
        <!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
        <service
            android:name="cn.jpush.android.service.DaemonService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.DaemonService" />
                <category android:name="grooter.mobile" />
            </intent-filter>
        </service>

        <!-- since 3.1.0 Required SDK 核心功能-->
        <provider
            android:authorities="grooter.mobile.DownloadProvider"
            android:name="cn.jpush.android.service.DownloadProvider"
            android:exported="true"
        />

        <!-- Required SDK核心功能-->
        <receiver
            android:name="cn.jpush.android.service.PushReceiver"
            android:enabled="true"
            android:exported="false">
            <intent-filter android:priority="1000">
                <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />   <!--Required  显示通知栏 -->
                <category android:name="grooter.mobile" />
            </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>

        <!-- Required SDK核心功能-->
        <receiver android:name="cn.jpush.android.service.AlarmReceiver" android:exported="false"/>

        <!-- User defined.  For test only  用户自定义的广播接收器-->
        <receiver
            android:name="com.example.jpushdemo.MyReceiver"
            android:exported="false"
            android:enabled="true">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required  用户注册SDK的intent-->
                <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required  用户接收SDK消息的intent-->
                <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required  用户接收SDK通知栏信息的intent-->
                <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required  用户打开自定义通知栏的intent-->
                <action android:name="cn.jpush.android.intent.CONNECTION" /><!-- 接收网络变化 连接/断开 since 1.6.3 -->
                <category android:name="grooter.mobile" />
            </intent-filter>
        </receiver>

        <!-- User defined.  For test only  用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
        <receiver android:name="com.example.jpushdemo.MyJPushMessageReceiver">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
                <category android:name="grooter.mobile"></category>
            </intent-filter>
        </receiver>
        <!-- Required  . Enable it you can get statistics data with channel -->
        <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
        <meta-data android:name="JPUSH_APPKEY" android:value="71f48ade06f25353f61157ea" /> <!--  </>值来自开发者平台取得的AppKey-->

    </application>
</manifest>

  There are two types of content in this code that need to be changed, one is the package name, and the other is appkey. The package name can be searched for the package name of the current demo and then changed to your own package name. The appkey is at the end of the code.
  Some of the code can be deleted, such as TestActivit, MainActivity can be deleted, because this is an activity of the demo, but we have our own activity, and a custom receiver can also be deleted, if you don't delete it, you need to Create the corresponding class yourself, or drag the corresponding class in the demo.

6. Add initialization code to the BaseApp class (if not found, it can be searched globally):

JPushInterface.setDebugMode(true);
JPushInterface.init(this);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324481117&siteId=291194637