-
-
Save secondsun/b01c3446095fb29a85e3 to your computer and use it in GitHub Desktop.
Comparing APIs before and after Registration_refactor PR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushApplication extends Application { | |
private PushRegistrar registrar; | |
private PushConfig config; | |
private final Registrations registrations = new Registrations(); | |
private static final String VARIANT_ID = ""; | |
private static final String SECRET = ""; | |
private static final String GCM_SENDER_ID = ""; | |
private static final String UNIFIED_PUSH_URL = ""; | |
private static final String MY_ALIAS = ""; | |
public void onCreate() { | |
super.onCreate(); | |
try { | |
config = new PushConfig(new URL(UNIFIED_PUSH_URL), GCM_SENDER_ID); | |
config.setVariantID(VARIANT_ID); | |
config.setSecret(SECRET); | |
config.setAlias(MY_ALIAS); | |
registrar = registrations.push("registrar", config); | |
} catch (MalformedURLException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
public void register() { | |
registrar.register(getApplicationContext(), new MyCallback<Void>()); | |
} | |
public void unregister() { | |
registrar.unregister(getApplicationContext(), new MyCallback<Void>()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushApplication extends Application { | |
private Registrar registrar; | |
private PushConfig config; | |
private static final String VARIANT_ID = ""; | |
private static final String SECRET = ""; | |
private static final String GCM_SENDER_ID = ""; | |
private static final String UNIFIED_PUSH_URL = ""; | |
private static final String MY_ALIAS = ""; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
try { | |
final Registrar r = new Registrar(new URL(UNIFIED_PUSH_URL)); | |
PushConfig config = new PushConfig(GCM_SENDER_ID); | |
config.setVariantID(VARIANT_ID); | |
config.setSecret(SECRET); | |
config.setAlias(MY_ALIAS); | |
r.register(getApplicationContext(), config, new Callback<Void>() { | |
private static final long serialVersionUID = 1L; | |
@Override | |
public void onSuccess(Void ignore) { | |
registrar = r; | |
} | |
@Override | |
public void onFailure(Exception exception) { | |
Log.e(TAG, exception.getMessage(), exception); | |
} | |
}); | |
} catch (MalformedURLException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment