Isabelle Isabelle - 8 days ago 6
Android Question

Parse.com Initialization Server

I've been recently included in an ongoing Android app project that I have to update. While changing some of the app's functionality I stumbled upon some Parse initialization code, and, after some research, guessed that it was supposed to enable Android Push Notifications through Parse.

The problem is, after reading some Parse tutorials and trying lots and lots of key search terms, I could not find in the code where the Parse server is set and where it is connecting. The currently configuration is:

// Using Parse-1.3.0.jar lib

// My Activity
Parse.initialize(this, "APP_ID", "CLIENT_KEY");
ParseAnalytics.trackAppOpened(getIntent());
PushService.setDefaultPushCallback(this, MYACTIVITY.class);
ParseInstallation.getCurrentInstallation().saveInBackground();

// My AndroidManifest.xml
<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>

// That seems to be the only Parse related configuration...


So how does the application know where to connect? Which Parse server configuration is it using?

I know the Parse Service is discontinued and if we want to continue to use Parse we may have to set up a hosted Parse Server, but first we need to understand how is it connecting to Parse now.

Any help would be appreciated.

Thanks for your time.

Answer

The parse SDK is, by default, connecting to the hosted parse server at https://api.parse.com.

As soon as you have your parse-server instance set up and running, just initialise the SDK with a configuration object:

Parse.Configuration configuration = new Parse.Configuration.Builder(this)
        .applicationId(BuildConfig.PARSE_APPLICATION_ID)
        .server("https://www.website.com/parse/")
        .clientKey(BuildConfig.PARSE_CLIENT_KEY)
        .build();
Parse.initialize(configuration);

Feel free to ask if you have any other question. I’m not sure I got what you wanted to ask.

  • ParseAnalytics stuff can probably go away, should not be supported anymore.
  • we may have to set up a hosted Parse Server: if discontinuing the app for a while is a problem for you, I think you should hurry up, because the deadline (28 Jan I think?) is getting close.
  • Push notifications won’t work with your configuration when you update to own parse-server. Read here for more information. You will have to get your own GCM (or FCM, it’s the same in this case) keys:

By default, the hosted Parse service (parse.com) sends pushes to your Android app with its own GCM sender ID. With your Parse Server, this setup will no longer work. Instead, your Parse Server will send GCM pushes with its own GCM sender ID and API key. You should register a GCM sender ID and update your app as soon as possible.

The sender Id will then need to be used in the manifest as:

<meta-data android:name="com.parse.push.gcm_sender_id"
           android:value="@string/gcm_sender_id" />

Anyway, this is a long road from where you are now, at this point you should probably take care of setting up a parse-server as soon as possible, and only then upgrade the Android app accordingly.