:::: 개발 ::::/:::: 안드로이드 ::::

GCM 내 앱에 적용

nayha 2014. 3. 2. 13:55

기존 GCM 테스트 앱에서  


기본 설정 퍼미션(권한) 부분 가져오 Manifest


<!-- GCM requires Android SDK version 2.2 (API level 8) or above. -->

    <!-- The targetSdkVersion is optional, but it's always a good practice

         to target higher versions. -->

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>


    <!-- GCM connects to Google Services. -->

    <uses-permission android:name="android.permission.INTERNET" />


    <!-- GCM requires a Google account. -->

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />


    <!-- Keeps the processor from sleeping when a message is received. -->

    <uses-permission android:name="android.permission.WAKE_LOCK" />


    <!--

     Creates a custom permission so only this app can receive its messages.


     NOTE: the permission *must* be called PACKAGE.permission.C2D_MESSAGE,

           where PACKAGE is the application's package name.

    -->

    <permission

        android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE"

        android:protectionLevel="signature" />

    <uses-permission

        android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE" />


    <!-- This app has permission to register and receive data message. -->

    <uses-permission

        android:name="com.google.android.c2dm.permission.RECEIVE" />



어플 설정에 recever 

<!--

          BroadcastReceiver that will receive intents from GCM

          services and handle them to the custom IntentService.


          The com.google.android.c2dm.permission.SEND permission is necessary

          so only GCM services can send data messages for the app.

        -->

        <receiver

            android:name="com.google.android.gcm.GCMBroadcastReceiver"

            android:permission="com.google.android.c2dm.permission.SEND" >

            <intent-filter>

                <!-- Receives the actual messages. -->

                <action android:name="com.google.android.c2dm.intent.RECEIVE" />

                <!-- Receives the registration id. -->

                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.google.android.gcm.demo.app" />

            </intent-filter>

        </receiver>


        <!--

          Application-specific subclass of GCMBaseIntentService that will

          handle received messages.


          By default, it must be named .GCMIntentService, unless the

          application uses a custom BroadcastReceiver that redefines its name.

        -->

        <service android:name=".GCMIntentService" />




반응형