Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.

Updates. See commit details. #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.iml
.idea
target/
target/
.DS_Store
2 changes: 2 additions & 0 deletions Samples/ActivityFeed/activityfeed/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 23
Expand All @@ -24,4 +25,5 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile project(':UsergridAndroidSDK')
compile "com.google.firebase:firebase-messaging:9.0.0"
}
42 changes: 42 additions & 0 deletions Samples/ActivityFeed/activityfeed/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"project_info": {
"project_number": "468982482457",
"firebase_url": "https://activity-feed-727db.firebaseio.com",
"project_id": "activity-feed-727db",
"storage_bucket": "activity-feed-727db.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:468982482457:android:8b607d8ef09dec5c",
"android_client_info": {
"package_name": "org.apache.usergrid.activityfeed"
}
},
"oauth_client": [
{
"client_id": "468982482457-l9cjoki8hotacuouj75b73mpbc827bjo.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAIbLcFcdh64wNWb7CZAt3jyj3tauZujqM"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
Binary file removed Samples/ActivityFeed/activityfeed/libs/gcm.jar
Binary file not shown.
36 changes: 20 additions & 16 deletions Samples/ActivityFeed/activityfeed/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.apache.usergrid.activityfeed">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<permission
android:name="org.apache.usergrid.activityfeed.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />

<uses-permission android:name="org.apache.usergrid.activityfeed.gcm.permission.C2D_MESSAGE" />

<application
android:allowBackup="true"
Expand All @@ -19,17 +18,22 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">

<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<service
android:name=".PushMessageListenerService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />

<category android:name="org.apache.usergrid.activityfeed" />
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".PushTokenListenerService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</service>

<activity
android:name=".activities.MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,19 @@
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.google.android.gcm.GCMBaseIntentService;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import org.apache.usergrid.activityfeed.activities.MainActivity;

public class GCMIntentService extends GCMBaseIntentService {

public GCMIntentService() {
super(UsergridManager.GCM_SENDER_ID);
}

@Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered: " + registrationId);
UsergridManager.registerPush(context,registrationId);
}

@Override
protected void onUnregistered(Context context, String registrationId) {
Log.i(TAG, "Device unregistered");
}

@Override
protected void onMessage(Context context, Intent intent) {
String message = intent.getExtras().getString("data");
Log.i(TAG, "Received message: " + message);
generateNotification(context, message);
}

@Override
protected void onDeletedMessages(Context context, int total) {
Log.i(TAG, "Received deleted messages notification");
String message = "GCM server deleted " + total +" pending messages!";
generateNotification(context, message);
}
public class PushMessageListenerService extends FirebaseMessagingService {

@Override
public void onError(Context context, String errorId) {
Log.i(TAG, "Received error: " + errorId);
public void onMessageReceived(RemoteMessage message){
PushMessageListenerService.generateNotification(this,message.getData().get("data"));
}

@Override
protected boolean onRecoverableError(Context context, String errorId) {
Log.i(TAG, "Received recoverable error: " + errorId);
return super.onRecoverableError(context, errorId);
}

/**
* Issues a Notification to inform the user that server has sent a message.
*/
private static void generateNotification(Context context, String message) {
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
Expand Down Expand Up @@ -84,4 +46,5 @@ private static void generateNotification(Context context, String message) {
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.apache.usergrid.activityfeed;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

public class PushTokenListenerService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
if( refreshedToken != null ) {
UsergridManager.registerPush(this,refreshedToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.util.Log;

import com.google.android.gcm.GCMRegistrar;
import com.google.firebase.iid.FirebaseInstanceId;

import org.apache.usergrid.activityfeed.activities.FeedActivity;
import org.apache.usergrid.activityfeed.callbacks.GetFeedMessagesCallback;
Expand Down Expand Up @@ -51,13 +50,12 @@

public final class UsergridManager {

private static final String ORG_ID = "rwalsh";
private static final String APP_ID = "sandbox";
private static final String BASE_URL = "https://api.usergrid.com";
private static final String ANDROID_NOTIFIER_ID = "androidPushNotifier";
private static final String ORG_ID = "rjwalsh";
private static final String APP_ID = "sdk.demo";
private static final String BASE_URL = "https://apibaas-trial.apigee.net";
private static final String ANDROID_NOTIFIER_ID = "fcmActivityFeed";

public static String GCM_SENDER_ID = "186455511595";
public static String GCM_REGISTRATION_ID = "";
public static String FCM_TOKEN = "";

private UsergridManager() {}

Expand All @@ -73,20 +71,16 @@ public void onResponse(@NotNull UsergridResponse response) { }
}

public static void registerPush(Context context) {
final String regId = GCMRegistrar.getRegistrationId(context);
if ("".equals(regId)) {
GCMRegistrar.register(context, GCM_SENDER_ID);
} else {
if (GCMRegistrar.isRegisteredOnServer(context)) {
Log.i("", "Already registered with GCM");
} else {
registerPush(context, regId);
try {
FCM_TOKEN = FirebaseInstanceId.getInstance().getToken();
if( FCM_TOKEN != null ) {
registerPush(context, FCM_TOKEN);
}
}
} catch (Exception ignored) {}
}

public static void registerPush(@NonNull final Context context, @NonNull final String registrationId) {
GCM_REGISTRATION_ID = registrationId;
FCM_TOKEN = registrationId;
UsergridAsync.applyPushToken(context, registrationId, ANDROID_NOTIFIER_ID, new UsergridResponseCallback() {
@Override
public void onResponse(@NonNull UsergridResponse response) {
Expand Down
4 changes: 2 additions & 2 deletions Samples/ActivityFeed/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'

classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 2 additions & 2 deletions Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Thu Jan 05 15:33:52 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
3 changes: 2 additions & 1 deletion Samples/Push/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 2 additions & 2 deletions Samples/Push/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Thu Jan 05 15:33:52 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
2 changes: 2 additions & 0 deletions Samples/Push/push/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 23
Expand All @@ -24,4 +25,5 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile project(':UsergridAndroidSDK')
compile "com.google.firebase:firebase-messaging:9.0.0"
}
54 changes: 54 additions & 0 deletions Samples/Push/push/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"project_info": {
"project_number": "186455511595",
"firebase_url": "https://apigeepush.firebaseio.com",
"project_id": "apigeepush",
"storage_bucket": "apigeepush.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:186455511595:android:7ac854c0e66d35f3",
"android_client_info": {
"package_name": "org.apache.usergrid.push"
}
},
"oauth_client": [
{
"client_id": "186455511595-p2o4g7iug5e4tcp9vtriqqo691bhmk9h.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "org.apache.usergrid.push",
"certificate_hash": "40B96A76FEA181EC71BB8E86ECD42407C469F898"
}
},
{
"client_id": "186455511595-ge27hngtfbn214e0499ufmtmnorfdptr.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "186455511595-d6kc7n52d5fq2o6g5lakqs0v6gib3h10.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDFqoXcWKR_c-XPxHsD7slYv0dXEksQWhA"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
Binary file removed Samples/Push/push/libs/gcm.jar
Binary file not shown.
Loading