Skip to content
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
18 changes: 14 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ inspector/ios-inspector/.DS_Store
#FORGE
module/manifest.json
module/.DS_Store
module/android
module/docs/*
module/identity.json
module/inspector_config.json
Expand All @@ -146,9 +145,9 @@ module/tests*

.DS_Store
.trigger
.hash
.lib

inspector/ios-inspector/.hash
inspector/ios-inspector/.DS_Store
inspector/ios-inspector/ForgeCore.bundle
inspector/ios-inspector/ForgeCore.framework
Expand All @@ -157,8 +156,6 @@ inspector/ios-inspector/build
inspector/ios-inspector/ForgeInspector.xcodeproj/project.pbxproj
inspector/ios-inspector/ForgeInspector.xcodeproj/project.xcworkspace/xcshareddata/ForgeInspector.xccheckout
inspector/ios-inspector.*
inspector/*an
inspector/an-inspector.*
inspector/ios-inspector/ForgeModule/ForgeModule-Prefix.pch
inspector/ios-inspector/ForgeModule/ForgeModule.xcodeproj/project.pbxproj
inspector/ios-inspector/ForgeModule/ForgeModule.xcodeproj/xcshareddata/xcschemes/ForgeModule.xcscheme
Expand All @@ -168,3 +165,16 @@ ForgeInspector.xcodeproj/project.xcworkspace/xcuserdata/horak.xcuserdatad/UserIn
inspector/ios-inspector/ForgeInspector.xcodeproj/project.xcworkspace/*
inspector/ios-inspector/ForgeInspector.xcodeproj/xcuserdata/*


inspector/an-inspector.*
inspector/an-inspector/ForgeInspector
inspector/an-inspector/ForgeModule/.settings
inspector/an-inspector/ForgeModule/libs
inspector/an-inspector/ForgeModule/res
inspector/an-inspector/ForgeModule/gen
inspector/an-inspector/ForgeModule/bin
inspector/an-inspector/ForgeModule/trigger-gen
inspector/an-inspector/ForgeModule/.classpath
inspector/an-inspector/ForgeModule/.project
inspector/an-inspector/ForgeModule/AndroidManifest.xml
inspector/an-inspector/ForgeModule/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.trigger.forge.android.modules.push;

import java.io.IOException;

import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.gson.JsonPrimitive;

import io.trigger.forge.android.core.ForgeApp;
import io.trigger.forge.android.core.ForgeTask;

public class API {

private static boolean isRegistered = false;

public static void registerWithAPNS(final ForgeTask task){
final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(ForgeApp.getApp());
try {
String senderID = ForgeApp.configForPlugin("push").get("gcm-sender-id").getAsString();
//TODO: the register method is deprecated
String regid = gcm.register(senderID);
isRegistered = true;
task.success(regid);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove repeated logic?

ForgeApp.event("onDidRegisterWithAPNS", new JsonPrimitive(regid));
} catch (IOException e) {
task.error(e.getMessage());
}
}
public static void checkIfRegisteredWithAPNS(final ForgeTask task){
task.success(isRegistered);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.trigger.forge.android.modules.push;

import io.trigger.forge.android.core.ForgeApp;
import io.trigger.forge.android.core.ForgeEventListener;

public class EventListener extends ForgeEventListener {

@Override
public void onRestart() {
ForgeApp.event("push.resume", null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.trigger.forge.android.modules.push;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class GCMReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
ComponentName comp = new ComponentName(context.getPackageName(), GCMService.class.getName());
context.startService(intent.setComponent(comp));
setResultCode(Activity.RESULT_OK);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.trigger.forge.android.modules.push;

import io.trigger.forge.android.core.ForgeApp;

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import com.kinvey.android.push.KinveyGCMService;

public class GCMService extends KinveyGCMService {

private static final Gson gson = new Gson();

@Override
public Class getReceiver() {
return GCMReceiver.class;
}

@Override
public void onDelete(String arg0) {
Log.i(TAG, arg0);
}

@Override
public void onError(String arg0) {
Log.e(TAG, arg0);
}

@Override
public void onMessage(String message) {
PushMessage notification;
try {
notification = gson.fromJson(message, PushMessage.class);
} catch (JsonSyntaxException e) {
notification = new PushMessage(message);
}
notification.show();
ForgeApp.event("push.message", new JsonPrimitive(message));
}

@Override
public void onRegistered(String arg0) {
Log.i(TAG, arg0);

}

@Override
public void onUnregistered(String arg0) {
Log.i(TAG, arg0);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package io.trigger.forge.android.modules.push;

import io.trigger.forge.android.core.ForgeApp;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

public class PushMessage {

private String message;
private String from;
private String subject;


public PushMessage(String message) {
this(message, "Fetchnotes", "");
}
public PushMessage(String message, String from, String subject) {
this.message = message;
this.from = from;
this.subject = subject;
}

public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public void show() {
Context context = ForgeApp.getApp();
Intent intent = new Intent(context, ForgeApp.getActivity().getClass());
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(ForgeApp.getResourceId("icons", "drawable"))
.setDefaults(Notification.DEFAULT_VIBRATE)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setContentTitle(from)
.setContentText(message);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.getNotification());
}

}
157 changes: 157 additions & 0 deletions module/android/build_steps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
[
{
"do": {
"android_add_permission": {
"permission": "android.permission.INTERNET"
}
}
},
{
"do": {
"android_add_permission": {
"permission": "android.permission.ACCESS_NETWORK_STATE"
}
}
},
{
"do": {
"android_add_permission": {
"permission": "android.permission.VIBRATE"
}
}
},
{
"do": {
"android_add_permission": {
"permission": "android.permission.WAKE_LOCK"
}
}
},
{
"do": {
"android_add_permission": {
"permission": "com.google.android.c2dm.permission.RECEIVE"
}
}
},
{
"do": {
"android_add_permission": {
"permission": "android.permission.BROADCAST_STICKY"
}
}
},
{
"do": {
"android_add_to_application_manifest": {
"element": {
"tag": "permission",
"attributes": {
"android:name": "io.trigger.forge.android.modules.push.permission.C2D_MESSAGE",
"android:protectionLevel": "signature"
}
}
}
}
},
{
"do": {
"android_add_permission": {
"permission": "io.trigger.forge.android.modules.push.permission.C2D_MESSAGE"
}
}
},
{
"do": {
"android_add_to_application_manifest": {
"element": {
"tag": "receiver",
"attributes": {
"android:name": "io.trigger.forge.android.modules.push.GCMReceiver",
"android:permission": "com.google.android.c2dm.permission.SEND"
},
"children": [{
"tag": "intent-filter",
"children": [{
"tag": "action",
"attributes": {
"android:name": "com.google.android.c2dm.intent.RECEIVE"
}
}, {
"tag": "action",
"attributes": {
"android:name": "com.google.android.c2dm.intent.REGISTRATION"
}
}, {
"tag": "category",
"attributes": {
"android:name": "io.trigger.forge.android.modules.push"
}
}]
}]
}
}
}
},
{
"do": {
"android_add_to_application_manifest": {
"element": {
"tag": "service",
"attributes": {
"android:name": "io.trigger.forge.android.modules.push.GCMService",
"android:label": "Push Notification Service"
}
}
}
}
},
{
"do": {
"android_add_to_application_manifest": {
"element": {
"tag": "meta-data",
"attributes": {
"android:name": "com.google.android.gms.version",
"android:value": "@integer/google_play_services_version"
}
}
}
}
},
{
"do": {
"android_add_proguard_rule": {
"rule": "-keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); }"
}
}
},
{
"do": {
"android_add_proguard_rule": {
"rule": "-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; }"
}
}
},
{
"do": {
"android_add_proguard_rule": {
"rule": "-keepnames @com.google.android.gms.common.annotation.KeepName class *"
}
}
},
{
"do": {
"android_add_proguard_rule": {
"rule": "-keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; }"
}
}
},
{
"do": {
"android_add_proguard_rule": {
"rule": "-keepnames class * implements android.os.Parcelable { public static final ** CREATOR; }"
}
}
}
]
Binary file added module/android/libs/gcm.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added module/android/libs/kinvey-android-lib-2.9.5.jar
Binary file not shown.
Binary file added module/android/libs/kinvey-java-2.9.5.jar
Binary file not shown.
Binary file added module/android/res/drawable-hdpi-v11/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-hdpi-v9/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-hdpi/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-mdpi-v11/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-mdpi-v9/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-mdpi/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-xhdpi-v11/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-xhdpi-v9/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-xhdpi/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-xxhdpi-v11/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-xxhdpi-v9/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added module/android/res/drawable-xxhdpi/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions module/android/res/values/version.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">7571000</integer>
</resources>
Loading