Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Adding FCM capability to the agent #347

Merged
merged 1 commit into from
Nov 24, 2016
Merged
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
1 change: 1 addition & 0 deletions modules/mobile-agents/android/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}

Expand Down
4 changes: 3 additions & 1 deletion modules/mobile-agents/android/client/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* under the License.
*/
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

repositories {
maven {
Expand Down Expand Up @@ -64,9 +65,10 @@ dependencies {
exclude module: 'junit'
}
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.6.0-rc3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0-rc3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0-rc3'
Expand Down
42 changes: 42 additions & 0 deletions modules/mobile-agents/android/client/client/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"project_info": {
"project_number": "919081834526",
"firebase_url": "https://wewrweragent.firebaseio.com",
"project_id": "wso2agent",
"storage_bucket": "wso2agent.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:917891897426:android:cb1a80b8fbeae4c0",
"android_client_info": {
"package_name": "org.wso2.emm.agent"
}
},
"oauth_client": [
{
"client_id": "9234081897234-j4f7tdaj1c6rad7bmqac05k3f3du66m1.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "rerwerwwerwerwerwer"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@
android:screenOrientation="unspecified"
android:excludeFromRecents="true"></activity>

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

<category android:name="org.wso2.emm.agent" />
</intent-filter>
</receiver>
<receiver
android:name=".services.AgentDeviceAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN"
Expand Down Expand Up @@ -171,10 +160,9 @@
</intent-filter>
</service>
<service
android:name=".GCMIntentService"
android:exported="false">
android:name=".FCMMessagingService">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
Expand Down Expand Up @@ -245,5 +233,13 @@
android:name=".services.AppLockService"
android:permission="org.wso2.emm.agent.permission.ACCESS"
android:exported="false" />

<service
android:name=".InstanceIDListenerService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,24 @@

package org.wso2.emm.agent;
import android.content.Context;
import android.os.Bundle;

import android.util.Log;
import com.google.android.gms.gcm.GcmListenerService;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import org.wso2.emm.agent.services.MessageProcessor;
import org.wso2.emm.agent.utils.CommonUtils;
import org.wso2.emm.agent.utils.Constants;
import org.wso2.emm.agent.utils.Preference;

/**
* IntentService responsible for handling GCM messages.
* IntentService responsible for handling FCM messages.
*/
public class GCMIntentService extends GcmListenerService {
public class FCMMessagingService extends FirebaseMessagingService {
private static final String TAG = FCMMessagingService.class.getName();

private static final String TAG = GCMIntentService.class.getName();

/**
* This method gets called when a GCM message is received. We use GCM as the device wake up
* method. Once the Agent receives a GCM notification, Agent polls the server for pending operations.
*/
@Override
public void onMessageReceived(String from, Bundle data) {
public void onMessageReceived(RemoteMessage message){
Context context = this.getApplicationContext();
MessageProcessor messageProcessor = new MessageProcessor(context);
try {
Expand All @@ -58,3 +53,4 @@ public void onMessageReceived(String from, Bundle data) {
}

}

This file was deleted.

Loading