├── .gitignore
├── AndroidManifest.xml
├── README.md
├── UNLICENSE
├── libs
├── Parse-1.5.0.jar
└── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ ├── happy.png
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── layout
│ └── activity_main.xml
├── menu
│ └── activity_main.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
└── values
│ ├── strings.xml
│ └── styles.xml
└── src
└── com
└── makemyandroidapp
└── parsenotificationexample
├── Keys.java
├── MainActivity.java
├── ParseApplication.java
└── ParseReceiver.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 |
15 | # Local configuration file (sdk path, etc)
16 | local.properties
17 |
18 | # Eclipse project files
19 | .classpath
20 | .project
21 | .settings/
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ParseNotificationExample
2 | ========================
3 | Example project that demonstrates how to setup an application to receive both basic, and custom data push notifications from http://parse.com
4 |
--------------------------------------------------------------------------------
/UNLICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/libs/Parse-1.5.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoamyGuy/ParseNotificationExample/2cd82a76758d22c5a50e0acffe22ccbfa871f657/libs/Parse-1.5.0.jar
--------------------------------------------------------------------------------
/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoamyGuy/ParseNotificationExample/2cd82a76758d22c5a50e0acffe22ccbfa871f657/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-17
15 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/happy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoamyGuy/ParseNotificationExample/2cd82a76758d22c5a50e0acffe22ccbfa871f657/res/drawable-hdpi/happy.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoamyGuy/ParseNotificationExample/2cd82a76758d22c5a50e0acffe22ccbfa871f657/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoamyGuy/ParseNotificationExample/2cd82a76758d22c5a50e0acffe22ccbfa871f657/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FoamyGuy/ParseNotificationExample/2cd82a76758d22c5a50e0acffe22ccbfa871f657/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ParseNotificationExample
5 | Hello world!
6 | Settings
7 |
8 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/src/com/makemyandroidapp/parsenotificationexample/Keys.java:
--------------------------------------------------------------------------------
1 | package com.makemyandroidapp.parsenotificationexample;
2 |
3 | public class Keys {
4 | // Fill in your keys
5 | protected static final String applicationId = "";
6 | protected static final String clientKey = "";
7 | }
8 |
--------------------------------------------------------------------------------
/src/com/makemyandroidapp/parsenotificationexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.makemyandroidapp.parsenotificationexample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.Menu;
6 |
7 | public class MainActivity extends Activity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 |
14 | }
15 |
16 | @Override
17 | public boolean onCreateOptionsMenu(Menu menu) {
18 | // Inflate the menu; this adds items to the action bar if it is present.
19 | getMenuInflater().inflate(R.menu.activity_main, menu);
20 | return true;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/com/makemyandroidapp/parsenotificationexample/ParseApplication.java:
--------------------------------------------------------------------------------
1 | package com.makemyandroidapp.parsenotificationexample;
2 |
3 | import com.parse.Parse;
4 | import com.parse.ParseInstallation;
5 | import com.parse.PushService;
6 |
7 | import android.app.Application;
8 |
9 | public class ParseApplication extends Application {
10 | @Override
11 | public void onCreate() {
12 | super.onCreate();
13 | Parse.initialize(this, Keys.applicationId, Keys.clientKey);
14 | PushService.setDefaultPushCallback(this, MainActivity.class);
15 | ParseInstallation.getCurrentInstallation().saveInBackground();
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/com/makemyandroidapp/parsenotificationexample/ParseReceiver.java:
--------------------------------------------------------------------------------
1 | package com.makemyandroidapp.parsenotificationexample;
2 |
3 | import java.util.Iterator;
4 |
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 |
8 | import android.app.Notification;
9 | import android.app.NotificationManager;
10 | import android.app.PendingIntent;
11 | import android.content.BroadcastReceiver;
12 | import android.content.Context;
13 | import android.content.Intent;
14 | import android.graphics.Bitmap;
15 | import android.graphics.BitmapFactory;
16 | import android.support.v4.app.NotificationCompat;
17 | import android.util.Log;
18 | /*****************************
19 | * This class will receive custom push notifications
20 | * from parse.com. These are different than the "plain"
21 | * message push notifications.
22 | *
23 | * There must be an action defined within the Intent-Filter
24 | * for this receiver in the manifest.xml file. And the same
25 | * action must be specified on the notification when it is
26 | * pushed.
27 | *
28 | * You can optionally pass JSON data from parse.com which will
29 | * be avaialable in the onReceive() method here.
30 | *****************************/
31 | public class ParseReceiver extends BroadcastReceiver {
32 | private final String TAG = "Parse Notification";
33 | private String msg = "";
34 | @Override
35 | public void onReceive(Context ctx, Intent intent) {
36 | Log.i(TAG, "PUSH RECEIVED!!!");
37 |
38 | try {
39 | String action = intent.getAction();
40 | String channel = intent.getExtras().getString("com.parse.Channel");
41 | JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
42 |
43 | Log.d(TAG, "got action " + action + " on channel " + channel + " with:");
44 | Iterator itr = json.keys();
45 | while (itr.hasNext()) {
46 | String key = (String) itr.next();
47 | Log.d(TAG, "..." + key + " => " + json.getString(key));
48 | if(key.equals("string")){
49 | msg = json.getString(key);
50 | }
51 | }
52 | } catch (JSONException e) {
53 | Log.d(TAG, "JSONException: " + e.getMessage());
54 | }
55 |
56 |
57 | Bitmap icon = BitmapFactory.decodeResource(ctx.getResources(),
58 | R.drawable.happy);
59 |
60 | Intent launchActivity = new Intent(ctx, MainActivity.class);
61 | PendingIntent pi = PendingIntent.getActivity(ctx, 0, launchActivity, 0);
62 |
63 | Notification noti = new NotificationCompat.Builder(ctx)
64 | .setContentTitle("PUSH RECEIVED")
65 | .setContentText(msg)
66 | .setSmallIcon(R.drawable.happy)
67 | .setLargeIcon(icon)
68 | .setContentIntent(pi)
69 | .setAutoCancel(true)
70 | .build();
71 |
72 | NotificationManager nm = (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
73 | nm.notify(0, noti);
74 |
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------