Parse does not update deviceToken on debug app whe

2019-06-14 11:09发布

问题:

I have two registered accounts in Parse, production and development. In my native android app I have two flavors as well, production and development. Each of them initializes Parse on the onCreate method of my application with the right client and application keys.

When the user starts the app, I can see in both Parse Installation dashboards the row of the installation being created. But for some reason, only on the production account the deviceToken gets updated and not on the development one. This is a big problem for me, because if Parse does not set the deviceToken automatically when saving the current Installation I cannot receive push notifications on those devices.

This is the part of the code that initializes Parse and the push Notification services:

public void init(boolean isDebug) {
    try {
        if(!isDebug){
            Parse.initialize(context, context.getResources().getString(R.string.parse_app_id), context.getResources().getString(R.string.parse_client_key));

        }
        else {
            Parse.initialize(context, context.getResources().getString(R.string.parse_dev_app_id), context.getResources().getString(R.string.parse_dev_client_key));
        }
        ParseInstallation.getCurrentInstallation().saveInBackground();
    } catch (Exception exp) {
        Log.d(TAG, exp.getMessage().toString());
    }
}

I also save the current installation when the user signs up or logs in :

public boolean saveUsernameInParseInstallation()
{
    ParseUser user = ParseUser.getCurrentUser();
    if(user == null) return false;
    else
    {
        ParseInstallation installation = ParseInstallation.getCurrentInstallation();
        installation.put("user",user.getUsername());
        installation.saveInBackground();
        return true;
    }
}

and this is the part of the manifest where I register all the receivers:

    <service android:name="com.parse.PushService" />
    <receiver android:name="com.parse.ParseBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>
    <receiver android:name=".utils.Parse.MyParsePushBroadcastReceiver"
              android:exported="false">
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>
    <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="com.myapp.cam"/>
        </intent-filter>
    </receiver>

I use a custom ParsePushBroadcastReceiver in order to change the different notification icons among others.

The weird thing about all of this is that all the settings in the debug Parse account are correctly set since the iOS version can see their deviceTokens updated and they can receive the push notifications on the development app too. So I assumed it has to be a problem on the way I register or initialize the ParseInstallation object, but I haven't been able to find it yet.

Any ideas why this is not working?