Urban Airship Android Client - Google GCM Push

來源:互聯網
上載者:User

下面的例子假定已經配置好了Google的GCM。

1. 首先添加gcm.jar包到libs目錄下,並將其加入classpath。

2. 首先修改AndroidManifest.xml檔案,添加對GCM的支援


[html] 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="urbanairship.client" 
    android:versionCode="1" 
    android:versionName="1.0" > 
 
    ... 
 
    <!-- BEGIN for Urban Airship GCM --> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
    <uses-permission android:name="urbanairship.client.permission.C2D_MESSAGE" /> 
    <permission android:name="urbanairship.client.permission.C2D_MESSAGE" android:protectionLevel="signature" /> 
    <!-- END for Urban Airship GCM --> 
 
    <application 
        android:name="urbanairship.client.MyApplication" 
        android:enabled="true" 
        android:icon="@drawable/ic_launcher" 
        android:label="@string/app_name" 
        android:theme="@style/AppTheme"  
        android:debuggable="true"> 
 
        ... 
         
        <!-- BEGIN for Urban Airship GCM --> 
        <receiver android:name="com.urbanairship.CoreReceiver" /> 
        <receiver 
            android:name="com.urbanairship.push.GCMPushReceiver" 
            android:permission="com.google.android.c2dm.permission.SEND" > 
            <intent-filter> 
                <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 
                <category android:name="urbanairship.client" /> 
            </intent-filter> 
        </receiver> 
        <!-- END for Urban Airship GCM --> 
         
        ... 
    </application> 
 
</manifest> 
3. 修改assets/airshipconfig.properties檔案
3.1 將其中的


[plain] 
transport=helium 
改成

[plain]
transport = gcm 
3.2 將其中的gcmSender設定為Google API project ID。
4. 運行程式測試,從Urban AirShip向此裝置發送通知,然後檢查狀態列。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.