Skip to content

Commit

Permalink
Refactored region end points and updated payloads (#25)
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

* Updated regions with correct values

* Refactored

* Updated read
  • Loading branch information
sam-almighty authored and srinivasannanduri committed Jan 23, 2018
1 parent 2d42bc7 commit 1dc935a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
})
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.ibm.mobilefirstplatform.clientsdk.android:core:[2.0.0,3.0.0)'
// compile 'com.ibm.mobilefirstplatform.clientsdk.android:core: 3.1.+'
compile 'com.squareup.picasso:picasso:+'
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,10 @@ private void register(final AppLaunchListener appLaunchListener, Hashtable param
Enumeration keys = parameters.keys();
while(keys.hasMoreElements()){
String key = (String) keys.nextElement();
initJson.put(key,parameters.get(key));
// initJson.put(key,parameters.get(key));
paramsJson.put(key,parameters.get(key));
}
initJson.put("attributes",paramsJson);
appLaunchCacheManager.addString(appLaunchConfig.getUserID()+"-"+appLaunchConfig.getBluemixRegion()+"-"+appLaunchConfig.getApplicationId()+"-params",paramsJson.toString());
}
//construct registration url
Expand Down Expand Up @@ -708,13 +709,15 @@ private void sendPostRequest(final String methodName, String url, JSONObject bod
Map<String, List<String>> headers = new HashMap<>();
List<String> headerValues = new ArrayList<>();
headerValues.add("application/json");
headers.put("Content-Type", headerValues);
// headerValues.add("application/json; charset = UTF-8");
headers.put("content-type", headerValues);
List<String> secretValues = new ArrayList<>();
secretValues.add(appLaunchConfig.getClientSecret());
headers.put("clientSecret", secretValues);
// headers.put("clientSecret",appLaunchConfig.getClientSecret());
postReq.setHeaders(headers);


postReq.send(appContext, body.toString(), new ResponseListener() {
@Override
public void onSuccess(Response response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
public enum ICRegion {


US_SOUTH(".us-south.containers.mybluemix.net"),
US_SOUTH(".ng.bluemix.net"),

UNITED_KINGDOM(".eu-gb.containers.mybluemix.net"),
UNITED_KINGDOM(".eu-gb.bluemix.net"),

SYDNEY(".sydney.containers.mybluemix.net"),
SYDNEY(".au-syd.bluemix.net"),

US_SOUTH_STAGING("-staging.us-south.containers.mybluemix.net"),
US_SOUTH_STAGING(".stage1.ng.bluemix.net"),

UNITED_KINGDOM_STAGING("-staging.eu-gb.containers.mybluemix.net"),
UNITED_KINGDOM_STAGING(".stage1.eu-gb.bluemix.net"),

SYDNEY_STAGING("-staging.sydney.containers.mybluemix.net"),
SYDNEY_STAGING(".stage1.au-syd.mybluemix.net"),

US_SOUTH_DEV("-dev.us-south.containers.mybluemix.net"),
US_SOUTH_DEV(".dev.ng.mybluemix.net"),

UNITED_KINGDOM_DEV("-dev.eu-gb.containers.mybluemix.net"),
UNITED_KINGDOM_DEV(".dev.eu-gb.bluemix.net"),

SYDNEY_DEV(".dev.au-syd.bluemix.net");

SYDNEY_DEV("-dev.sydney.containers.mybluemix.net");

private String region;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ private static String getPlatform() {
public static JSONObject getInitJson(Application application) {
JSONObject initObject = new JSONObject();
try {
initObject.put("model", getModel());
initObject.put("brand", getBrand());
initObject.put("OSVersion", getOSVersion());
// initObject.put("model", getModel());
// initObject.put("brand", getBrand());
// initObject.put("OSVersion", getOSVersion());
initObject.put("platform", getPlatform());
initObject.put("appId", getPackageName(application));
initObject.put("appVersion", "1.0.0");
initObject.put("appName", getAppName(application));
// initObject.put("appId", getPackageName(application));
// initObject.put("appVersion", "1.0.0");
// initObject.put("appName", getAppName(application));
} catch (JSONException e) {
initObject = null;
logger.error("Error creating init json " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ public class AppLaunchUrlBuilder {
private static String USERS = "/users";
private static String MOBILESERVICES = "https://applaunch";
private static String APPLAUNCH_CONTEXT = "/applaunch/v1";

private static String MOBILESERVICES_DEV="https://mobileservices-dev.us-south.containers.mybluemix.net";


public AppLaunchUrlBuilder(ICRegion region, String appID, String deviceID,String userId) {
this.baseURL = MOBILESERVICES + region.toString() + APPLAUNCH_CONTEXT;
if(region.equals(ICRegion.US_SOUTH_DEV)){
this.baseURL = MOBILESERVICES_DEV+APPLAUNCH_CONTEXT;
}else{
this.baseURL = MOBILESERVICES + region.toString() + APPLAUNCH_CONTEXT;
}
this.applicationID = appID;
this.deviceID = deviceID;
this.userId = userId;
Expand Down
1 change: 1 addition & 0 deletions AppLaunchClientAndroid/applaunchsample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.3.+'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.ibm.mobilefirstplatform.clientsdk.android:core:[2.0.0,3.0.0)'
// compile 'com.ibm.mobilefirstplatform.clientsdk.android:core: 3.1.4'
compile 'com.squareup.picasso:picasso:+'
compile project (':applaunch-client-android')
testCompile 'junit:junit:4.12'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ To use the Bluemix App Launch SDK include the following:
```
dependencies {
........
compile 'com.github.ibm-bluemix-mobile-services:bms-clientsdk-android-applaunch:0.0.1'
compile 'com.github.ibm-bluemix-mobile-services:bms-clientsdk-android-applaunch:0.0.5'
compile 'com.ibm.mobilefirstplatform.clientsdk.android:core:[2.0.0,3.0.0)'
.......
}
Expand Down

0 comments on commit 1dc935a

Please sign in to comment.