Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.json.JSONObject;
import org.wordpress.android.WordPress;
import org.wordpress.android.models.Note;
import org.wordpress.android.util.Utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -72,4 +73,11 @@ public static String unzipString(byte[] zbytes) {
}
return unzipped;
}

public static String getAppPushNotificationsName(){
if (Utils.isDebugBuild())
return "org.wordpress.android.debug.build";
else
return "org.wordpress.android.playstore";
}
}
16 changes: 16 additions & 0 deletions src/org/wordpress/android/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.net.NetworkInfo;
import android.util.TypedValue;

import org.wordpress.android.BuildConfig;
import org.wordpress.android.R;
import org.wordpress.android.WordPress;

Expand Down Expand Up @@ -70,4 +71,19 @@ public static boolean isNetworkAvailable() {
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}

/*
* Return true if Debug build. false otherwise.
*
* ADT (r17) or Higher => BuildConfig.java is generated automatically by Android build tools, and is placed into the gen folder.
*
* BuildConfig containing a DEBUG constant that is automatically set according to your build type.
* You can check the (BuildConfig.DEBUG) constant in your code to run debug-only functions.
*/
public static boolean isDebugBuild() {
if (BuildConfig.DEBUG) {
return true;
}
return false;
}
}
11 changes: 8 additions & 3 deletions src/org/xmlrpc/android/WPComXMLRPCApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.wordpress.android.Constants;
import org.wordpress.android.WordPress;
import org.wordpress.android.WordPressDB;
import org.wordpress.android.ui.notifications.NotificationUtils;
import org.wordpress.android.util.DeviceUtils;
import org.wordpress.android.util.MapUtils;

Expand Down Expand Up @@ -49,6 +50,7 @@ public void registerWPComToken(final Context ctx, String token) {
contentStruct.put("os_version", android.os.Build.VERSION.RELEASE);
contentStruct.put("device_uuid", uuid);
contentStruct.put("production", true); //production, NOT sandbox.
contentStruct.put("app_secret_key", NotificationUtils.getAppPushNotificationsName());

Object[] params = {
settings.getString(WordPress.WPCOM_USERNAME_PREFERENCE, ""),
Expand Down Expand Up @@ -80,7 +82,8 @@ public void unregisterWPComToken(Context ctx, String token) {
WordPressDB.decryptPassword(settings.getString(WordPress.WPCOM_PASSWORD_PREFERENCE, "")),
token,
false,
"android"
"android",
NotificationUtils.getAppPushNotificationsName()
};

XMLRPCClient client = new XMLRPCClient(URI.create(Constants.wpcomXMLRPCURL), "", "");
Expand Down Expand Up @@ -111,7 +114,8 @@ public void getNotificationSettings(final XMLRPCCallback callback, Context conte
settings.getString(WordPress.WPCOM_USERNAME_PREFERENCE, ""),
WordPressDB.decryptPassword(settings.getString(WordPress.WPCOM_PASSWORD_PREFERENCE, "")),
gcmToken,
"android"
"android",
NotificationUtils.getAppPushNotificationsName()
};

client.callAsync(new XMLRPCCallback() {
Expand Down Expand Up @@ -193,7 +197,8 @@ public void setNotificationSettings(Context context) {
WordPressDB.decryptPassword(settings.getString(WordPress.WPCOM_PASSWORD_PREFERENCE, "")),
updatedSettings,
gcmToken,
"android"
"android",
NotificationUtils.getAppPushNotificationsName()
};

client.callAsync(new XMLRPCCallback() {
Expand Down