Skip to content

Commit

Permalink
Updated url end point (#22)
Browse files Browse the repository at this point in the history
* Updated SDK to include BACKGROUND_REFRESH policy for actions

* Updated ReadMe for BACKGROUND_REFRESH

* Add Destroy method

* Included methods to clear cache

* Updated url end point
  • Loading branch information
sam-almighty authored and srinivasannanduri committed Jan 19, 2018
1 parent c670316 commit 2d42bc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public void onFailure(AppLaunchFailResponse failResponse) {
*/
public void destroy(final AppLaunchListener appLaunchListener){
//TODO : Cache Clearing Mechanism and Check device is registered or not
if (appLaunchConfig != null && this.clientSecret != null) {
//send all the analytics event to the server
sendLogs();
//construct registration url
Expand All @@ -183,18 +182,17 @@ public void destroy(final AppLaunchListener appLaunchListener){
@Override
public void onSuccess(AppLaunchResponse appLaunchResponse) {
// Clear all the cache

appLaunchCacheManager.destroyCache();
}

@Override
public void onFailure(AppLaunchFailResponse appLaunchFailResponse) {
appLaunchListener.onFailure(appLaunchFailResponse);
}
};
sendDeleteRequest(registrationUrl, appLaunchInternalListener);
}else{
throw new RuntimeException("Invalid Init paramters");
}
if(appLaunchCacheManager.getString(appLaunchConfig.getUserID()+"-"+appLaunchConfig.getBluemixRegion()+"-"+appLaunchConfig.getApplicationId(),null)!=null){
sendDeleteRequest(registrationUrl, appLaunchInternalListener);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ protected void initializeCache(Context context){
sharedpreferences = context.getSharedPreferences(APP_LAUNCH, Context.MODE_PRIVATE);
}

protected void destroyCache(){
SharedPreferences.Editor editor = getEditor();
editor.clear();
editor.commit();
}

protected String getString(String key, String defaultValue){
if(key!=null){
return sharedpreferences.getString(key,defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public class AppLaunchUrlBuilder {
private static String EVENTS = "/events";
private static String METRICS = "/metrics";
private static String USERS = "/users";
private static String MOBILESERVICES = "https://mobileservices";
private static String APPLAUNCH_CONTEXT = "/applaunch/v1";
private static String MOBILESERVICES = "https://applaunch";
private static String APPLAUNCH_CONTEXT = "/applaunch/v1";


public AppLaunchUrlBuilder(ICRegion region, String appID, String deviceID,String userId) {
this.baseURL = MOBILESERVICES + region.toString() + APPLAUNCH_CONTEXT;
Expand Down

0 comments on commit 2d42bc7

Please sign in to comment.