/** Unregister the device from GCM notifications */ public static void disablePushNotifications(final Context context) { if (MPUtility.isInstanceIdAvailable()) { new Thread( new Runnable() { @Override public void run() { PushRegistrationHelper.clearInstanceId(context); } }) .start(); } }
public static void requestInstanceId(final Context context, final String senderId) { if (getLatestPushRegistration(context) == null && MPUtility.isInstanceIdAvailable()) { final Runnable instanceRunnable = new Runnable() { @Override public void run() { try { String instanceId = InstanceID.getInstance(context).getToken(senderId, "GCM"); MParticle.getInstance().logPushRegistration(instanceId, senderId); } catch (Exception ex) { ConfigManager.log( MParticle.LogLevel.ERROR, "Error registering for GCM Instance ID: ", ex.getMessage()); } } }; if (Looper.getMainLooper() == Looper.myLooper()) { new Thread(instanceRunnable).start(); } else { instanceRunnable.run(); } } }