Pierre
Pierre

Reputation: 101

Android Parse, notifications and buildTypes

I am currently using parse to send and receive push notifications on an Android app.
Everything was fine until i added an application id suffix to my build.gradle for the debug build type:

defaultConfig {
    applicationId "com.example.myapp"
    ...
}

buildTypes {
    debug {
        applicationIdSuffix ".debug"
        ...
    }
    release {
        ...
    }
}

Now I can see in Parse that new installations are registered with the applicationId field : com.example.myapp.debug, so into the manifest file I used the following piece of code :

<receiver
        android:name="com.parse.GcmBroadcastReceiver"
        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="${applicationId}" />

        </intent-filter>
    </receiver>

Doing this i thought the registration would be dynamic according to the build type.

Actually it doesn't work : installations registered with the .debug suffix have no GCMSenderId nor DeviceToken, and so i can't receive any notification. I am obviously missing a point, or I didn't understand how the registration works, but i can't figure how to make it ok.
Does Parse use the applicationId to register the application, or the real package name (used for R) ?

Did anyone manage to handle parse notifications with different buildTypes (applicationId suffix) ?

Upvotes: 5

Views: 262

Answers (1)

Pierre
Pierre

Reputation: 101

Ok, I finally figured it out. I forgot to add the dynamic applicationId in the permission declaration...

<permission
    android:name="${applicationId}.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />

Problem solved.

Upvotes: 5

Related Questions