Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
new versions of libraries, fixes, improved logging
Browse files Browse the repository at this point in the history
  • Loading branch information
theganyo committed May 2, 2013
1 parent ad7f9fd commit 41b05ac
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 35 deletions.
Binary file added libs/slf4j-android-1.5.8.jar
Binary file not shown.
Binary file removed libs/slf4j-android-1.6.1-RC1.jar
Binary file not shown.
Binary file removed libs/spring-android-core-1.0.0.M4.jar
Binary file not shown.
Binary file added libs/spring-android-core-1.0.1.RELEASE.jar
Binary file not shown.
Binary file removed libs/spring-android-rest-template-1.0.0.M4.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
48 changes: 26 additions & 22 deletions src/com/ganyo/pushtest/AppServices.java
Expand Up @@ -38,13 +38,14 @@ static void login(final Context context) {

@Override
public void onResponse(ApiResponse apiResponse) {
Log.i(TAG, "authorize response: " + apiResponse);
Log.i(TAG, "login response: " + apiResponse);
registerPush(context);
}

@Override
public void onException(Exception e) {
Log.i(TAG, "authorize exception: " + e);
displayMessage(context, "Login Exception: " + e);
Log.i(TAG, "login exception: " + e);
}
});
} else {
Expand All @@ -64,23 +65,25 @@ static void register(final Context context, final String regId) {
public void onResponse(Device device) {
Log.i(TAG, "register response: " + device);
AppServices.device = device;

// uncomment to optionally connect Device to current User
// if (getClient().getLoggedInUser() != null) {
// getClient().connectEntitiesAsync("users", getClient().getLoggedInUser().getUuid().toString(),
// "devices", device.getUuid().toString(),
// new ApiResponseCallback() {
// @Override
// public void onResponse(ApiResponse apiResponse) {
// Log.i(TAG, "connect response: " + apiResponse);
// }
//
// @Override
// public void onException(Exception e) {
// Log.i(TAG, "connect exception: " + e);
// }
// });
// }
displayMessage(context, "Device registered as: " + regId);

// connect Device to current User - if there is one
if (getClient().getLoggedInUser() != null) {
getClient().connectEntitiesAsync("users", getClient().getLoggedInUser().getUuid().toString(),
"devices", device.getUuid().toString(),
new ApiResponseCallback() {
@Override
public void onResponse(ApiResponse apiResponse) {
Log.i(TAG, "connect response: " + apiResponse);
}

@Override
public void onException(Exception e) {
displayMessage(context, "Connect Exception: " + e);
Log.i(TAG, "connect exception: " + e);
}
});
}
}

@Override
Expand All @@ -90,13 +93,13 @@ public void onException(Exception e) {
}

@Override
public void onDeviceRegistration(Device device) { /* this won't be called */}
public void onDeviceRegistration(Device device) { /* this won't ever be called */ }
});
}

static void sendMyselfANotification(Context context) {
static void sendMyselfANotification(final Context context) {
if (device == null) {
displayMessage(context, "Device not registered.");
displayMessage(context, "Device not registered (yet?)");
}
else {
String entityPath = "devices/" + device.getUuid().toString() + "/notifications";
Expand All @@ -114,6 +117,7 @@ public void onResponse(ApiResponse apiResponse) {

@Override
public void onException(Exception e) {
displayMessage(context, "Send Exception: " + e);
Log.i(TAG, "send exception: " + e);
}
});
Expand Down
6 changes: 1 addition & 5 deletions src/com/ganyo/pushtest/MainActivity.java
Expand Up @@ -65,11 +65,7 @@ public void onReceive(Context context, Intent intent) {
* Take some action upon receiving a push notification here!
**/
String message = intent.getExtras().getString(EXTRA_MESSAGE);

if(message == null)
{
message = "Empty Message";
}
if (message == null) { message = "Empty Message"; }

Log.i(TAG, message);
messageTextView.append("\n" + message);
Expand Down
13 changes: 5 additions & 8 deletions src/com/ganyo/pushtest/Settings.java
@@ -1,21 +1,18 @@
package com.ganyo.pushtest;

import org.usergrid.android.client.Client;

/** Change these values to match your setup! */
public class Settings {

// Google Client Id from Google API Console
static final String GCM_SENDER_ID = "978423379483";
static final String GCM_SENDER_ID = "854525328487";

// Notifier Name created in app services
// Notifier Name in App Services
static final String NOTIFIER = "google";

// static final String API_URL = Client.PUBLIC_API_URL;
static final String API_URL = "http://10.0.0.3:8080";
static final String API_URL = "https://api.usergrid.com";

static final String ORG = "test-organization";
static final String APP = "test-app";
static final String ORG = "<<your org name here>>";
static final String APP = "sandbox";

// set these if you want to use a user login
static final String USER = null;
Expand Down

0 comments on commit 41b05ac

Please sign in to comment.