Skip to content
Browse files

Merge pull request #32 from urbanairship/intent-receiver-move

Move the intent receiver into the plugin.
  • Loading branch information...
2 parents b71c763 + ac613f7 commit 008337c6a61c3c4617ecb0fa9bd65a7476bd9ae1 @jtowle jtowle committed Mar 7, 2013
View
8 android-sample/AndroidManifest.xml
@@ -59,6 +59,10 @@
</intent-filter>
</activity>
+
+ <!-- REQUIRED for PhoneGap plugin callback support -->
+ <receiver android:name="com.urbanairship.phonegap.plugins.PushNotificationPluginIntentReceiver" />
+
<!-- REQUIRED for Urban Airship GCM-->
<receiver android:name="com.urbanairship.CoreReceiver" />
@@ -87,10 +91,6 @@
<!-- OPTIONAL (for segments support) -->
<service android:name="com.urbanairship.location.LocationService" android:label="Segments Service"/>
- <!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
- <!-- Replace the receiver below with your package and class name -->
- <receiver android:name="com.urbanairship.phonegap.sample.IntentReceiver" />
-
</application>
<uses-sdk android:minSdkVersion="5" />
View
33 android-sample/src/com/urbanairship/phonegap/plugins/PushNotificationPlugin.java
@@ -1,12 +1,13 @@
package com.urbanairship.phonegap.plugins;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import android.os.RemoteException;
+
+import com.urbanairship.Logger;
+import com.urbanairship.location.LocationPreferences;
+import com.urbanairship.location.UALocationManager;
+import com.urbanairship.push.PushManager;
+import com.urbanairship.push.PushPreferences;
+import com.urbanairship.util.ServiceNotBoundException;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
@@ -15,15 +16,13 @@
import org.json.JSONException;
import org.json.JSONObject;
-import android.os.RemoteException;
-
-import com.urbanairship.location.LocationPreferences;
-import com.urbanairship.location.UALocationManager;
-import com.urbanairship.Logger;
-import com.urbanairship.phonegap.sample.IntentReceiver;
-import com.urbanairship.push.PushManager;
-import com.urbanairship.push.PushPreferences;
-import com.urbanairship.util.ServiceNotBoundException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
public class PushNotificationPlugin extends Plugin {
final static String TAG = PushNotificationPlugin.class.getSimpleName();
@@ -105,7 +104,7 @@ public PluginResult execute(String action, JSONArray data, String callbackId) {
if (action.equals("enablePush")) {
PushManager.enablePush();
- PushManager.shared().setIntentReceiver(IntentReceiver.class);
+ PushManager.shared().setIntentReceiver(PushNotificationPluginIntentReceiver.class);
result = new PluginResult(Status.OK);
} else if (action.equals("disablePush")) {
PushManager.disablePush();
View
10 ...rship/phonegap/sample/IntentReceiver.java → ...PushNotificationPluginIntentReceiver.java
@@ -1,4 +1,4 @@
-package com.urbanairship.phonegap.sample;
+package com.urbanairship.phonegap.plugins;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -8,7 +8,7 @@
import com.urbanairship.Logger;
import com.urbanairship.UAirship;
import com.urbanairship.location.UALocationManager;
-import com.urbanairship.phonegap.plugins.PushNotificationPlugin;
+import com.urbanairship.phonegap.sample.UAPhonegapSample;
import com.urbanairship.push.PushManager;
import com.urbanairship.util.ServiceNotBoundException;
@@ -18,9 +18,7 @@
import java.util.Map;
import java.util.Set;
-public class IntentReceiver extends BroadcastReceiver {
-
- private static final String TAG = IntentReceiver.class.getSimpleName();
+public class PushNotificationPluginIntentReceiver extends BroadcastReceiver {
private Map<String, String> getNotificationExtras(Intent intent) {
Map<String, String> extrasMap = new HashMap<String, String>();
@@ -37,7 +35,7 @@
// (ACTION_PUSH_RECEIVED
// only)
PushManager.EXTRA_PUSH_ID,// internal UA push id
- PushManager.EXTRA_ALERT);// ignore aler
+ PushManager.EXTRA_ALERT);// ignore alert
if (ignoredKeys.contains(key)) {
continue;
}
View
3 android-sample/src/com/urbanairship/phonegap/sample/MainApplication.java
@@ -6,6 +6,7 @@
import com.urbanairship.Logger;
import com.urbanairship.UAirship;
+import com.urbanairship.phonegap.plugins.PushNotificationPluginIntentReceiver;
import com.urbanairship.push.PushManager;
public class MainApplication extends Application {
@@ -26,7 +27,7 @@ public void onCreate() {
super.onCreate();
UAirship.takeOff(this);
PushManager.enablePush();
- PushManager.shared().setIntentReceiver(IntentReceiver.class);
+ PushManager.shared().setIntentReceiver(PushNotificationPluginIntentReceiver.class);
}
public void onStop() {

0 comments on commit 008337c

Please sign in to comment.
Something went wrong with that request. Please try again.