Jacksonkr
Jacksonkr

Reputation: 32207

GCM Generates new registration IDs for the same phone

I'm using one device for testing and I'm getting a lot of new registration IDs from it. Not every time the app is built, but sometimes. I'm not sure what the deal is. How do I get it to use the same id? Isn't that what is supposed to happen?

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="company.android.phone.TheApp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />
    
    <!-- for push notifications -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- 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" />
    <!-- For performance testing a trace file is saved to the SD card -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    <uses-permission android:name="android.permission.GET_TASKS" /> 
    
    <permission android:name="company.android.phone.TheApp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="company.android.phone.TheApp.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    
    <supports-screens
        android:resizeable="true"
        android:smallScreens="false"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="false"
        android:anyDensity="true" />

    <application
        android:icon="@drawable/app_icon"
        android:label="@string/app_name" >
        <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" 
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="company.android.phone.TheApp" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="company.android.phone.TheApp" />
            </intent-filter>
        </receiver>
        <activity 
            android:name=".SplashActivity"
            android:theme="@style/Theme.Splash"
            android:screenOrientation="portrait"
            android:noHistory="true" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:label="@string/app_name"
            android:windowSoftInputMode="stateVisible|adjustPan"
            android:name=".TheAppActivity"
            android:screenOrientation="portrait" >
        </activity>
        <activity 
            android:name=".MainActivity" 
            android:windowSoftInputMode="stateVisible|adjustPan"
            android:screenOrientation="portrait" />
        <activity android:name=".WebViewActivity" 
            android:windowSoftInputMode="stateVisible|adjustPan"
            android:screenOrientation="portrait" />
        <service android:name=".GCMIntentService" />
    </application>
</manifest>

Upvotes: 0

Views: 406

Answers (1)

fgeorgiew
fgeorgiew

Reputation: 1204

You have no warranty that your Registration Id will always be the same for your device.

The registration ID lasts until the Android application explicitly unregisters itself, or until Google refreshes the registration ID for your Android application.

For more info look here "Enabling GCM": http://developer.android.com/guide/google/gcm/gcm.html

Upvotes: 2

Related Questions