Edit on March 7, 2013: Please read this blog entry.
As I've been working my way through a sample application that makes use of Parse.com and PhoneGap, I wanted to take a look at how Parse handles Push Notifications. I assumed it would be easy and I'd simply include it into my series, but it turned out to be a more complex than I anticipated. Therefore, I've decided to blog about it on its own so as to keep things as simple and direct as possible. In the end, the process to get notifications working with PhoneGap and Parse wasn't terribly difficult, but there are a few things you have to orchestrate just right to get the desired results.
The first thing I need to warn you about is that notifications are going to be slightly different based on each platform. In general, you can do many of the same things between Android and iOS, but there are a few differences. You can take a look at the Android docs and the iOS docs as well as checking out a video the Parse team made just for iOS. You may notice that the JavaScript API has a section on Push Notifications as well, but it only supports creating new notifications. This confused me for a while until I remembered that outside of native applications, it wouldn't make sense for JavaScript to handle receiving notifications. Therefore, you have to use a native solution. Luckily PhoneGap allows us to do that and make use of the JavaScript API as well.
In this blog post I'll be using Android. Only the initial setup aspects though will be Android specific, The PhoneGap code we use later should work fine in iOS as well.
Note though that you will need to get your hands dirty a bit and work with Java. You don't need to actually write any Java, but this does mean that PhoneGap Build will not be an option for apps making use of notifications. I used Eclipse for my application but you can probably get away with just using the command-line tools with PhoneGap.
Part One - Eclipse/Java Setup
Ok, so let's get started. First - create an Android PhoneGap project. I used the AppLaud plugin to make it super easy. I tend to be antsy about such things so before I did anything else I confirmed it ran on my mobile device. Also, I assume you have some Parse.com application already created. I'm not talking about a mobile application I mean an application defined at Parse's web site. I made use of my CowTipLine application.
Go to the Parse downloads and get the Android SDK. Note that this SDK is just a jar file (Parse-1.1.6.jar). Copy this jar file to your PhoneGap project's libs folder:

At this point you probably want to refresh the view in Eclipse so it recognizes a new file. As we all know, Eclipse gets snooty if you dare to actually use your file system.
Now - following along the Android notifications docs, you're asked to modify your AndroidManifest.xml to add the following lines:
These lines basically act as a listener for Parse.com push notifications. They will enable your application to recognize and respond to the notifications sent out by the server.
The Parse docs then tell you to add three sets of permissions, but by default PhoneGap already has two of them set. You should only need to add the RECEIVE_BOOT_COMPLETED permission from the set below:
Ok, now you need to get into the Java a bit. When you created your application, you had to give it a package name. I called mine org.camden.test1. I ended up with a Java file called MyPhoneGapActivity.java. You can find this under the src folder.

Do not worry about the com.borismus.webintent folder. You will not have it yet and we'll come to that later.
You don't normally need to edit this file if you use the AppLaud plugin. If you built the project by hand following the PhoneGap Android guide then you have already worked with this file a bit.
Get this file open, and do the following:
- Add an import com.parse.*; below your other imports.
- Add a Parse.initailize(this, a, b) line in your onCreate method. "a" is your application key and "b" is your client key.
- Finally, add PushService.subscribe(this, "", MyPhoneGapActivity.class). Your "So and So.class" will differ depending on the name of your file. This line handles telling the application to listen in for messages from Parse. Parse supports multiple channels for filtered notifications, but the empty string represents the "broadcast" channel.
Here is my entire Java file.
Ok, at this point you want to ensure the application still compiles. Hit the nice little green arrow Eclipse button to rerun the application. In theory, you will see nothing different, but you want to ensure it at least runs ok on your device. Also, by running the application once, your application "subscribes" to push notifications from your application on Parse. That will be crucial for the next step.
Testing Notifications at Parse
I know I sound like a Parse fanboy (even though they don't seem to want to ever tweet about my blog posts ;) but I cannot stress how nice the developer tools are at Parse. Creating messages can be done with Android, iOS, REST, and the JavaScript API. But they went ahead and built in a push notifications panel on their application dashboard:

I recognize that screen shot has a lot of information on it, so let me quickly review it. You can see a list of all previously sent messages on top. Beneath it is a form to let you send messages. I mentioned above that applications can choose to subscribe to a particular channel. What channels you use are entirely dependent on your application. For now you will just ignore this and use the default Broadcast channel. In the Push Data box, keep the radio button at the default (Message) and enter something wise.

Hit the Send button and you should see - pretty darn immediately - the alert arrive on your device:

You can even close the application. If you send a new notification and select it in your Android... err.... whatever they call it (notification tray?) your application should open up.
Congratulations. You can now send notifications to your device.
Responding Intelligently to Notifications
So all of the above took me less than an hour. It was pretty cut and dry. But then I hit a pretty big roadblock. How could I make my application recognize when it was loaded via a notification and actually tell me what the notification was?
From what I read in the Android docs, it seemed to imply that you had to write a custom Java class. I wasn't opposed to this, but I really wanted a solution that would let me use JavaScript to respond to the notification.
I went back to the article I wrote back in May about Intents and PhoneGap. In that article I discussed how the WebIntents PhoneGap plugin would give us access to both creating and responding to intents with JavaScript.
I won't repeat the instructions from that article, but the basics are - you copy the jar from that plugin (remember in that first screen shot when I said you wouldn't have that particular folder?) as well as the JavaScript file and then add a script tag reference in your index.html to load it.
The WebIntents plugin has a few APIs, but the ones we care about are hasExtra and getExtra. hasExtra is used to see if extra "stuff" was passed in from the intent that loaded us and getExtra is what actually gets the data. This is where I got stuck though. The WebIntents docs show using a few constants (EXTRA_TEXT, EXTRA_SUBJECT, EXTRA_STREAM, and EXTRA_EMAIL) and I assumed I had to use one of those four. I built quick blocks of code to check for all four, updated my application on the device, sent a message, clicked on the notification, and waited to see which JavaScript block would pass the getExtra test. Unfortunately none of them did.
At this point I figured I was pretty much toast. I Googled a bit. Scratched my head. Pouted a bit too. Finally, I tried something new. In my getExtra call, I tried using what I had seen as a class related to Push Notifications:
window.plugins.webintent.hasExtra("com.parse.Data"
To my surprise, this worked! So it turns out the WebIntent plugin's JavaScript API can work with any form of intent data as long as you know the proper identifier. I quickly whipped up the following:
All I do is run the has test followed by a get call. I take the data, JSON stringify it, and log it to my console.

And that's it. Obviously real code would parse this data and do, well, whatever you want with it. As should be clear from the Parse.com form, you can send more than simple messages. Complex structures of data can be sent to your listening devices. Again, the whole Push Notification feature as a whole is very powerful. I definitely encourage you to look at it yourself, and knowing that you can use it within PhoneGap as well just makes it even better.
If you have any questions, or suggestions for improvement, just leave a comment below.
Archived Comments
thanks a lot for sharing sir.. this tutorial will helps me to make an apps someday, hehe..
thanks.. will be looking at doing this shortly in an app too..
I would be wonderful integrated at Phonegap build
Not sure it would be possible, Carlitux. That being said, you could automate the builds locally using the command line along with a tool like ANT.
But PhoneGap Build are working to offer plugins integration at cloud and PushWoosh has prepared the plugin to include at PG Build.... Only wait to pg to include it
I just compiled with Eclipse + Cordova 2.1.0 and the app crash at start!
some help?
I ask me!, it works if I put all uses-permission
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
@Carlitux: To your first comment, it is possible PG Build in the future will support the WebIntent plugin, but that isn't enough. Reread the first half of this where I talk about the Java changes that have to be made as well.
To your second comment - check the console in Eclipse to see what is reported.
Someone has tried to use javascript api to send on phonegap ?
Are you asking if it is possible? It definitely is and is described in the JavaScript API/Guide.
Nice tutorial. I was trying to figure this out on my own earlier before I read this, but did way more work then I needed too haha. Thanks Sir!
If you don't mind me asking, what did yo do wrong? I'm curious about the mistakes you made. Not to laugh at you of course (grin), but basically, what you did wrong others may do as well.
I signed up for an account at parse.com. I downloaded the files it gave me for android. I then tried to implement those files into an app I am making. I copied the Parse.jar, then I also copied the whole parse package in the src and put it into my app. I then changed the App id and Client id. I also added all the code needed in the androidmanifest.xml. Then it told me to add a test object and i had no idea where to put it so i just put it in the class it gave me. And it wouldn't work lol. I didn't know what I was doing haha.
Then I read your blog post. All I needed was the Parse.jar, code for the androidmanifest.xml, and the code that went into the main activity. I didn't need to transfer the whole package over from the files the website gave me lol.
Ok, thanks for sharing that.
A video tutorial will be great !!!
Goji, how do you imagine a video tutorial would go? I'm not sure how it would help here, but I'd be willing to do one for sure.
Great tutorial! I tried to follow your guide. I was able to get the phone to subscribe to the broadcast. I then tried to send from Parse Web UI. I got the sound and vibrate but no alert. I looked at log and all i see is this.
10-23 19:57:09.824: ERROR/NotificationService(109): Ignoring notification with icon==0: Notification(contentView=com.testapp/0x1090098 vibrate=default,sound=default,defaults=0xffffffff,flags=0x10)
Any idea of what is happening?
Wow, that seems odd. To get everything _but_ the actual notification. Um - can you share the code with me?
Sure. I am using Intellij and followed this link to create the project - http://therockncoder.blogsp...
Here's part of the AndroidManifest.xml:
--------------------------------------------
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="@string/app_name">
<activity android:name="TestActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
My Activity:
-------------------------------------------
package com.example;
import android.app.Activity;
import android.os.Bundle;
import com.parse.Parse;
import com.parse.PushService;
import org.apache.cordova.*;
public class TestActivity extends DroidGap {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
Parse.initialize(this, "ux9bn4dSY8R6QMVro9eN0bToXWwGSa2DMAri0pkc", "KOC2KVtrY3oIzuKKea6ejsqgZ84t3p8txO5oELPo");
PushService.subscribe(this, "", TestActivity.class);
}
}
I've spent more than 2 days on this now. I've tried the app on 4.0 emulator, 4.0 virtualbox VM and my 4.0 android phone, none of them work :(
Could you possibly send me a copy of the app? (I'll consider it NDA, delete when done, etc.)
Hello,
I have just followed your tutorial and worked perfectly for me.I try to implement a score application, when I receive the notification is there a way to show the notification as a view on html inside PhoneGap?
Thank you very much,
If I read you right, could you not use what I talked about in the second half - ie, knowing that the user loaded the app based on a notification?
Thank you.
Is there a way to send live data into Phonegap page with Parse or any other idea?
Sorry - what? That's kinda of the point of notifications - to send data. :) Again though I may be misreading you. I know in my samples I focused on simple strings, but you can send 'data' as well (JSON objects).
Thank you Raymond,
Is it possible to show the message inside Phonegap page after you clicked on the notification?
Do you understand how - in the second portion of this entry - I discuss how to notice the app was launched by a notification? What you're asking is covered by that. Right?
I fully understood you entry and believe me it is great. After the app is launched by the notification is there a way to put that notification directly in a Phonegap page?
Given that your can use JS code to handle that, you would then do whatever you want. So for example, if you make use of jQuery, you can inject the message into the DOM.
I may be misunderstanding you though. This _should_ be simple, right? (And I don't mean that to offend - I may not have done a well enough job explaining things.)
If you look at my last code block, the logic inside function(d) where I just console.log it - that's where you would add "real" code.
Ok thank you.
It will be very useful to convert this into PhoneGap + Parse tutoial?
https://www.parse.com/tutor...
I didn't watch the video, but if it is just displaying content, that's very easy to do. Did you see my other Parse/PhoneGap blog series?
For folks curious about the issue Tom ran into above, it came down to this.
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="15" />
Apparently, when installed, it would make an alert sound, but not show the text, as Tom described. I saw it too. When changed to
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15" />
it worked. I'm thinking maybe the Android SDK version 9 didn't support the type of push notifications Parse was sending out.
Great Blog! Really appreciate - also the CowTipLine. Question... in the beginning you mention: "You may notice that the JavaScript API has a section on Push Notifications as well, but it only supports creating new notifications. This confused me for a while until I remembered that outside of native applications, it wouldn't make sense for JavaScript to handle receiving notifications. Therefore, you have to use a native solution". Are you saying that Parse.com Push Notifications could never work as a "Web App"?
@Steve: Correct. Of course, I hate to say never. You could find other ways of doing something similar I suppose. You could build your own messaging system and simply run a Parse query every 60 seconds for "Messages updated since now-60."
Hey Raymond. Continuing to research, I found a couple of options including Pusher.com and alertrocket.com. I haven't researched in depth, but it appears they do just that (HTML5 push notification). I'm not sure how that plays with Parse.com or Phonegap. Also, hmmmmm, possible the easiest way is just as you describe having the mobile app wake up and query for new message. Great. thanks for ideas.
That is, afaik, not the same as what we are talking about here. (But I'd be happy to be proven wrong. ;)
My understanding is that it is pretty much the same thing. I'd be curious to know why you think it's different. I am really a newbie to this stuff, so, heck whadoiknow. Anyway, Pusher.com and others are using WebSockets (HTML5). I've asked Parse.com folks when they plan to support WebSockets. They said they would get back to me on this, but after several queries, no reply. I'm wondering if the reason why Parse.com only does iOS and Android PUSH is that you can't do PUSH with WEB without WebSockets...... Hmmm. wonder if you could do both Parse.com and PUSHER.com from the same WebAPP, and how that would play with Phonegap.
Steve - and again - I'm talking with <100% certainty (grin) - so yes, Pusher is a WebSocket implementation (I believe it essentially shims websockets for browsers that don't support it.) But websockets connect your browser and your server. It doesn't connect your browser to Parse.com's server.
Correct. So, a single WebApp would have to have 2 simultaneous connections up at the same time..... one to Parse.com and one to Pusher.com. I have no clue as to whether this would work.
I don't believe you can open a WebSocket connection to another server at all. (Stress - believe.)
Raymond: I tried to dig deeper on this issue. With my limited knowledge of telcom protocols and models I plumb don't know what to think so I posted a question @ Pusher.com. Phil @ Pusher indicates that it's no problem do to concurrent http and websocket comm to a web app.
http://pusher.tenderapp.com...
http://pusher.tenderapp.com...
Can I simultaneously have the browser communicate to the database server https while concurrently (well, not really concurrently, but
it should appear to the user as concurrent) receiving PUSH notifications
from Pusher.com??
Phil's answer: When you update the database you can then publish any new or updated information through Pusher to all connected users, yes.
So maybe I'm getting confused here. Originally, this was about getting push notifications to your mobile app (which just so happened to be built in PhoneGap). You then asked about regular HTML web apps. And in my mind, I thought you still meant Parse. But if you wanted to get a notification "in general", then web sockets would work fine, and Pusher should be fine for that, but to be clear, we aren't talking about Parse notifications anymore. You can't create a notification from Parse and have the web app get it.
Terribly sorry. To recap: issue is that Parse.com does not currently have a JavaScript push notification. As I understand Phil from Pusher.com, a single JavaScript mobile web app could in fact use Parse.com for database storage AND Pusher.com for push notification concurrently. JavaScript Web App would then be ported to native apps with PhoneGap (same code across all platforms).
Pusher would give you notifications, but *not* Parse.com notifications. That's a critical thing to keep in mind.
If you are still talking about PhoneGap though, this whole thread of ours doesn't make sense to me, as I described how to make it work (yes you go to Java, but your code app is still HTML/JS).
Hi ,
I am using parse notifications with PhoneGap.(cordova 2.1.0). Devices are getting registered on parse.com, but when i send the notifications, devices are not receiving these notifications
My actvity class is:
package com.phone;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import com.parse.Parse; import com.parse.PushService;
public class ParsePushActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
Parse.initialize(this,"app key","client key");
PushService.subscribe(this, "", ParsePushActivity.class);
}
}
while index.html is :
<!DOCTYPE HTML>
<html> <head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
</head> <body >
<h1>Welcome to Cordova!</h1>
<h2>this file is located at assets/www/index.html</h2>
</body> </html>
and manifest file :-
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/..."
package="com.phone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name="com.phone.ParsePushActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver"> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter> </receiver>
</application>
</manifest>
Please help..
To be clear, your device isn't getting the notification, right? It isn't some other issue - like the device gets the notification but it doesn't load the app when clicked.
yup, devices are not receiving any notifications, even though they(devices) are getting registered on parse.com.
Look at the comment I made earlier to the guy who had the wrong minSDKVersion. Yours matches, but try adding the targetsdk version to match what I had in the comment. Also, ensure you've run the app at least once.
in the DDMS of Eclipse
message: could not connect to push server
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
We're you offline perhaps? Try again.
can download the code, please?
thanks
I don't have a download for this, but if you follow the directions carefully you shouldn't have an issue recreating it.
Hi Raymond!
Great tutorial, but I'm having some troubles with the last part: notification on device.
In device appears "DEVICE IS READY". It also registers with PARSE.COM, but when I send a push notification from Parse's website it doesn't show on device.
I've checked all twice and twice again. I'm using Phonegap 2.5.
I'm using a Galaxy Tab 2, Android 4.0
Thank you in advance.
Best regards!
Erich: Please see my update.
what intent filter are you using in the android manifest, my code to read the hasextra is not firing at all so I think I am missing this bit in my manifest.
I'm just using what you see above. Are you getting the notifications at least? If not - see my update.
I am getting the alerts just fine...
it's something with the code block below, when I comment out from the code block from where it says // start to // finish the function works (I get the alerts).
Uncommented, I do not get the alerts, which is why I thought it was the intent-filter (ie I am trying to read an intent it doesn't know about),
this script is the listed last in my header, under where all the other javascript source statements are, including the webintent.js declaration is.
<script>
alert("this script launched");
function init() {
document.addEventListener("deviceready",device_Ready,false);
}
function device_Ready() {
alert("Device Ready Fired");
// start
window.plugins.webintent.hasExtra("com.parse.Data",
function(has) {
if(has) {
window.plugins.webintent.getExtra("com.parse.Data",
function(d) {
alert("we have extra data");
//console.log(JSON.stringify(d))
}, function() {
// There was no extra supplied.
alert("we do not have extra data");
}
);
}, function() {
alert('fail');
}
);
// finish
}
</script>
Err .. above, where I say I am getting the alerts just fine, I should have said "I am getting the push notifications just fine"
Sorry
Let me try. In my last test, I was just working on _getting_ notifications.
Ok, I'm not sure what to tell you, but in my test (again, with following the Note at the very top), the webintent plugin works for me.
It's got to be a problem with my Cordova version, I'm using 2.1.0 and have these warnings:
Description Resource Path Location Type
The import android.util.Log is never used WebIntent.java /testapp/src/com/borismus/webintent line 13 Java Problem
The method getContext() from the type CordovaInterface is deprecated WebIntent.java /testapp/src/com/borismus/webintent line 76 Java Problem
The method getContext() from the type CordovaInterface is deprecated WebIntent.java /testapp/src/com/borismus/webintent line 84 Java Problem
The method getContext() from the type CordovaInterface is deprecated WebIntent.java /testapp/src/com/borismus/webintent line 96 Java Problem
The method getContext() from the type CordovaInterface is deprecated WebIntent.java /testapp/src/com/borismus/webintent line 187 Java Problem
Can you not try the latest?
I already have, webintent generates twice the warnings with 2.5.0 and 2.4.0.
Using Cordova 2.5.0:
Errors:
Description Resource Path Location Type
The method getContext() is undefined for the type CordovaInterface WebIntent.java /TestApp/src/com/borismus/webintent line 76 Java Problem
The method getContext() is undefined for the type CordovaInterface WebIntent.java /TestApp/src/com/borismus/webintent line 84 Java Problem
The method getContext() is undefined for the type CordovaInterface WebIntent.java /TestApp/src/com/borismus/webintent line 96 Java Problem
The method getContext() is undefined for the type CordovaInterface WebIntent.java /TestApp/src/com/borismus/webintent line 187 Java Problem
Warnings:
The method success(PluginResult, String) from the type Plugin is deprecated WebIntent.java /TestApp/src/com/borismus/webintent line 145 Java Problem
The type Plugin is deprecated WebIntent.java /TestApp/src/com/borismus/webintent line 16 Java Problem
The type Plugin is deprecated WebIntent.java /TestApp/src/com/borismus/webintent line 30 Java Problem
Hi, thanks very much for your tutorial.
Wondering what would be different to get this up and running with iOS and Javascript? Would I just get the iOs SDK or something? Help!
I haven't looked into iOS/Push yet. But I can share some articles. Note - these do NOT use Parse.
First is this article by my coworker, Holly. It describes the Push support available via another plugin and compatible with PhoneGap Build: http://devgirl.org/2013/01/...
Here is another article I'd recommend by Holly: http://devgirl.org/2012/12/...
@Christopher: I bet you are using an incorrect version. Try downloading the Java from here: https://github.com/phonegap...
Oh and get the latest JavaScript file as well of course.
Thanks Raymond. I actually followed the ios tutorial and got basic push notifications to wrok first go, (what the hell?! ) Now onto responding intelligently to these.. eg. open a specific page, call a specific part of the app etc.. I will post my findings here. The world needs more people like you, sharing and saving people hours of time and frustration!!!!
You are most welcome, and definitely, please share what you find.
OK I had a lot of problems with my eclipse version/build and it not generally cleaning things up/updating things.
*Pro Tip - make changes to your Eclipse project, do a project >> clean >> close Eclipse >> [navigate to your project directory and delete the bin and gen folders >> restart Eclipse.
That aside...
I feel there is an error in your javascript checking for getExtra:
window.plugins.webintent.hasExtra("com.parse.Data",
function(has) {
if(has) {
window.plugins.webintent.getExtra("com.parse.Data",
function(d) {
console.log(JSON.stringify(d))
}, function() {
// There was no extra supplied.
}
);
}, function() {
alert('fail');
}
);
it seemed like the last line is missing a closing brace before the closing parens and semi-colon.
So I modified it to this:
window.plugins.webintent.hasExtra("com.parse.Data",
function(has) {
if(has) {
window.plugins.webintent.getExtra("com.parse.Data",
function(d) {
console.log(JSON.stringify(d))
}, function() {
// There was no extra supplied.
}
);
}, function() {
alert('fail');
}
});
But then there was an error barking about the comma before the function that calls alert('fail'); so I took that out and have it working to let me know I got data!
here is my ending code sample:
<script>
function init() {
document.addEventListener("deviceready",deviceReady,false);
}
function deviceReady() {
alert("Device Ready");
window.plugins.webintent.hasExtra("com.parse.Data",
function(has) {
if(has) {
window.plugins.webintent.getExtra("com.parse.Data",
function(d) {
//console.log(JSON.stringify(d))
alert('App invoked from alert with data');
}, function() {
// There was no extra supplied.
alert('No data passed');
}
);
}
});
}
</script>
However I never get the 'No data passed' message...
You are absolutely right about the JS error - and I apologize. I saw that when updating my code for PhoneGap 2.5, but forgot to really dig into and mention it here!
Btw - I strongly recommend skipping Eclipse. Unless you like it of course. I do everything in a nicer editor like Brackets and simply build/deploy at the command line.
Could you post an updated version of the javascript/snippet/code, I am concerned on how to get the fail function to work just in case of an exception?
Yeah - may be a few days. On the road.
Hi Raymond,
First of all thank you very for this tutorial. I've followed it and it works flawless.
However, I've been stuck and maybe you can help me. My question is: how could I save current user in parse installation data so that I can send to him a specific notification if I can not do it from Javascript? I mean, is there any way store it using cloud code or something like that? I know that it can be done using the parse rest api, but the problem is that in order to do that I need to know the device installation object id and I can not find the way to obtain it.
Again, thank you very much. I will be looking forward to hearing from you.
Ezequiel, I had the same issue you have - and it annoyed me for a while. You're thinking the wrong way around, the installation ID is already specifically associated with the device when you use Java or IOS to setup the Parse plugin natively.
What you need to look at doing is write a basic plugin so that
HTML/JQUERY button pressed -> Calls Native Code -> Runs Native Code and Returns Success/Error - > Passes result back to Web window
At least that's how I achieved it.
@Ezequiel, are you perhaps talking about device to device notifications? What exactly is your use case here?
Device to device notifications, or notifications based on subscriptions. Eg a user chooses to follow "North America" or "South America" - they subscribe to a specific channel. In order to do so, you need the device ID.
For those using Phonegap, it's hard to get out of the javascript frame of mind. You can't get the device ID via Javascript. It's stored in the Installation object with the Java code or IOS code that you used to setup.
I managed to write a basic phonegap plugin in about 5 minutes (after 3 hours of research!) I will have to do the Android soon, so if you're interested bookmark and I will post it later
By the way, for device to device notifications, I used a combination of capital letter A+objectId (from user table) to create a channel that can be used to individlally message from user to user within my application. For some reason a channel cannot start with a number, but objectIds do. Doh.
I achiieved this in the same way, by using javascript to grab user's ID at logon, put an A in front of it, and then pass to the subscribe function in the native code via phonegap cordova.exec() function written. Check out phonegap page for examples
i follow the tutorial and i successfully make send notification but the problem that notifications Only show when app is open or running in background , i need to push notification and see it in status bar when app is totally closed .
Odd. What platform and version?
it solved , but it toke about 10 minutes to push notification when app is closed
@Raymond Camden
Great article.
My advice to everyone who tries to follow this guide is not to use phonegap 2.7.0. Apparently deprecated org.apache.cordova.api.Plugin class was removed from this version and you will have to edit WebIntent class to extend CordovaPlugin instead of Plugin to make it work.
@hmedRagheb
If you haven't figured out already, you have to call Parse.initialize method in your application class, not in the activity class. Otherwise it takes about 10 minutes for push notification to be delivered when application is closed, gods know why.
@Raymond Camden. It's a great article . Two things. On Android i got it to work only after setting this in my only activity,
super.loadUrl("file:///android_asset/www/index.html", 15000);
Parse.initialize(this, "bla", "bla");
PushService.setDefaultPushCallback(this, MyApp.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
PushService.subscribe(this, "Broadcast", MyApp.class)
I' using cordova 2.2.0 BTW.
If this might be helpfull for other i'm glad. Second, is there anyone that found a solution for the IOS Intelligent handling. I have just pieces of information, and the Webintent is a Android specific option.
Any help would be greatly appreciated.
It isn't Parse, but, an iOS example using PGB: http://devgirl.org/2013/01/...
Also: http://devgirl.org/2012/10/...
And when a tutorial like this with Puship? ;-)
Heh probably never. I think one of my coworkers covered that though.
Hi, I already register my app,but when i send a push notificaion, a little pop-up in the top of the screen appear with my message, why the app doesnt show the message in a Alert or what would be the code that I need for my app to mantain the app alert to show the push message when a notification arrive for her?
Push notifications are native - they aren't like alerts you run from your PG code. You don't get to control how they look (afaik).
Ok, but is normal that when i send the push, only a little pop up in the top appear? I think that an Alert will show in my app
Yes - every device - and every OS version - handles notifications slightly different.
Ok, so could you tell me how or where is the section that i need to change to catch that message and show it in an Alert?
Another question, this kind of notifications don't need GCM? I don't need to register me at this? or a PlugIn for this?
I don't think you *can* change it. It's baked into the OS. You get a notice, it does X. Users can configure how the notices appear, but not you (the app developer). Not as far as I know.
I did not register w/ Google to do my testing on Android.
Raymond could you tell me where did you put this section of the code
window.plugins.webintent.hasExtra("com.parse.Data"
in your porject?
like in the index.html, or in the NAME.js?
I use your fragment of code and paste it in my index.html at the script part, but when I run it tell me that
E/Web Console(25048): Uncaught TypeError: Cannot call method 'hasExtra' of undefined at file:///android_asset/www/js/webintent.js:75
you have a solution for that?
Luis: It is in my JavaScript code. As to your error, it sounds like webintent - as a plugin - didn't load properly. I'd double check that.
Its this the plug in that u use? https://github.com/phonegap...
Raymond, I fix the error, but I don't receive the message in the console, but I receive the push from parse, and I need that text, because if i can send it in the console, I can send it in an alert!
U dont have an example? a project? something that work that you can give to me?
Thanks
Comment 1: AFAIK, yes.
Comment 2: The only example is what I have here, Luis.
Btw - please be sure you read the follow up to this blog entry. It is linked to at the very top.
Raymond. I have an app developed with Sencha Touch 2 + PhoneGap.
I've already set the Parse and my app already receives pushes notifications in both Android and iOS devices.
Now I'm having a problem. Android devices with version prior than 4, on tap in the notification, if the app is already open, it restarts.
In Android device with version 4 or later, when the app is opened, it only brings the app from background to foreground.
I've tried search this and can not find a solution. I don't know if it's something related to Parse or PhoneGap.
You have some information about it?
I appreciate the help
Raymon, I already do everything what you says in it work!
Thanks a lot!
I have another question for you,
You think that it is possible that when the notification arrive, I can send the alert or the message at console with the content, i mean that I don't need to click the push that arrive, that be more automatic or immediately?
You mean force the app open? I don't think so.
I mean like an event that catch the message inmediatly, because in iOS u can do it but I dont know how to do it on android
Raymond I also discover something....
When I click the push notification, my app start over again, why?
I need at least that return from the background, not that re-run the app
For example:
When I receibe a message in my phone and I'm in the app of message, I dont need to re-open the app to see the message, in some apps, the message is open to me in an alert, thats what i want
Sorry Luis I do not know. Best I can recommend is asking up on the PhoneGap google group. If you do figure out why, I'd love to know.
So, You click on the push notification and the app restart and you show the containt of the message? There is no way to do it without restart the app at leat? I mean only return the app and show me the content, not restart the app?
I really don't know. It has been a while since I tested this. Sorry Luis.
I think the plugin Webintent doesn't work with new Cordova 3.0.0.
When is the new plugin coming up?
You need to ask the author.
Oops! I thought you were the author
Can notifications be used with Windows 8?
Not sure - I'd check the Parse site to see if it is supported. Let us know if you do.
Reading these comments it seems that the issue I am having has been solved.
I need to add the owner ID of the device to the installation object to allow me to advance target push notifications.
I am setting the installation object with Android SDK but then when someone logs in I use the JS SDK.
I would like to know how I can access the installation ID from Android from the web view.
Very simple procedure easy to follow, Thanks for the wonderful post sir :)
Thanks for the great tutorial. Can I just confirm that:
I can use the Parse Javascript SDK for a Phonegap app (android and iOS) and can receive Parse push notifications if I use this Java hack? (some of the comment threads confused me)
Thanks Again :)
It isn't a Java hack per se (ok, I'm being picky), but you are essentially right. :)
Push Notification in Android App Close Off
I am using phonegap (2.9), and want to add parse.com push notification support. I followed the quickstart
1. android virtual device test OK
2. with real android phone test, after sending out push notification , i get error message on the phone and i was requested to close off the app
3. any body can help please thanks
package com.phonegap.xxx;
import android.os.Bundle; import org.apache.cordova.*; import com.parse.Parse; import com.parse.ParseAnalytics; import com.parse.PushService;
public class Xxx extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
Parse.initialize(this, "APP_KEY", "CLIENT_KEY");
PushService.setDefaultPushCallback(this, Xxx.class);
PushService.subscribe(this, "", Xxx.class);
ParseAnalytics.trackAppOpened(getIntent());
}
}
Hi Ray, thanks for the tutorial.
I follow all the steps (think in the right way), but when i send a push notification from parse.com, it doesn't appear into my app and i don't know what i'm doing wrong.
Have you got any suggestion?
kind regards
Brus
Solved on my own. the problem was not adding the PushService.setDefaultPushCallback(this, Activity.class);
Thanks for the tutorial.
Brus
Thank you for adding this, Brus!
Im using cordova 3.3 with CLI, and build it locally. I followed your tutorial, but the build failed when I added the code in my activity.class. I guess this is because it couldn't find the parse.jar (which is the android sdk?). I tried to put the parse.jar in platforms/android/libs, and in platforms/android/CrodvaLib/libs without any luck. Any idea what may be wrong?
Hi Raymond I really love your tutorial, and it helped me a lot! I did not implement the webIntent because I only need to display the notification and be able to click on it. However, I met one problem that I don't really know how to fix. The notifications work perfect, but I get an alert message when Im not using the app that says "<appname> has stopped", do you know what can cause this problem? If you want me to add some code Im happy to do so. Thanks on advance!
The error occurs when I add the service and receiver tag in the AndroidManifest.xml. This is how it looks like:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="4" android:versionName="1.3.0" android:windowSoftInputMode="adjustPan" package="com.guessSound.guessSound" xmlns:android="http://schemas.android.com/...">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:debuggable="false" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="GuessThisSound" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.vending.BILLING" />
</manifest>
Sorry the code above was wrong, the code below is the correct one
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="4" android:versionName="1.3.0" android:windowSoftInputMode="adjustPan" package="com.guessSound.guessSound" xmlns:android="http://schemas.android.com/...">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:debuggable="false" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="com.guessSound.guessSound.GuessThisSound" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.vending.BILLING" />
</manifest>
After some debugging and looking in the logcat, I found out the source to my problem.
E/AndroidRuntime(14166): FATAL EXCEPTION: main
E/AndroidRuntime(14166): java.lang.RuntimeException: Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
However, I cant really understand why this happen when I actually initialize parse when I open the app.
import android.os.Bundle;
import org.apache.cordova.*;
import com.parse.*;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseInstallation;
import com.parse.PushService;
// import android.webkit.WebView;
public class GuessThisSound extends CordovaActivity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
// // Set by <content src="index.html" /> in config.xml
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(Config.getStartUrl(),3000);
Parse.initialize(this, "bByxR67VDCIY0Q6OZUDiTjUteBh4pzMmWlaXndD2", "9APpCFsVFz9Eg5Nu3razMYCjMpna6GlTSwqtpcuu");
PushService.setDefaultPushCallback(this, GuessThisSound.class);
PushService.subscribe(this, "Broadcast", GuessThisSound.class);
//super.loadUrl("file:///android_asset/www/index.html")
}
}
@TB: I honestly don't know - I'd suggest posting to the Parse forums as it has been a while since I did this. If you could post back when you get a response, I know myself and others would appreciate it.
Hi Raymond,
Awesome post.. It is so much simpler and easy to follow the steps mentioned by you rather than the steps mentioned on parse.com itself.
However.. I have a small problem.. I want to send parse.com push notifications to all the devices registered with the app, but from a PHP script file on my server.. What I basically mean is, I run the PHP file on my server and once the file is executed, the push notification will be sent to all the devices registered with that particular app key..
I tried a few codes & blog posts on parse.com but none worked for me..
It would be great if you could help me out..
Thanks..
Karan
Well, did you check the docs?
https://parse.com/docs/push...
hi sir,
is there a way i can subscribe to channels from my javascript.if i use the js sdk then i think it is not possible as the installation object can be referred from js sdk.i found this plugin-
https://github.com/avivais/...
but i am not able to understand how to use it ?
can you help me out?
I haven't used this plugin so I can't help - but have you tried reaching out to the plugin author?
yup i have contacted him.moreover tried to follow this article-
https://wait4ideas.wordpres...
still not working..
created a test repo-
https://github.com/mshukla1...
if you are interested you can go through that and help me debug :D
anyway thank you sir,i have learned many things from your site keep writing :)
It didn't work for me. Too much webintent plugins and none work!!
As this post is nearly two years old, you may want to try something newer - https://github.com/phonegap....
Hi Raymond, awesome blog. I need your help , i start building my mobile application using js , parse and phonegap for notification. I able to register my mobile at parse.com but i not receiving any notification from parse.com . why this happen? I did try upgraded my version as your comment past year back.
Sorry, I haven't played with this in a *long* time. Best I can suggest is to post to their forums. I found them to be pretty responsive there. If you are following what they doc and it is not working, then they should be able to help.
Its okay Raymond i manage to solve it, just add PushService.setDefaultPushCallback(this, Activity.class); into my code...thanks
Thanks for sharing the solution!
I did exactly as mentioned.. I can send the notifications from parse.com where 1 recipient (i.e. my test app) has been registered..
But I am not getting those notifs on my android emulator
M getting The method subscribe(Context, String, Class) from the type PushService is deprecated .... Can someone help...
Usefull post, do ypu know if is it possible to know if app is receiving a push notification when app is open and reading message?
I haven't used Push in a while, but thats fairly standard.
but in a cordova app what kind of event have I to test? I can't use 'on-receive' from push-plugin 'cause doesn't work with parse but I'm checking the java code (I'm a VB programmer) and maybe I found the way to read the push from an already open app.
I'd have to check the docs - as I said - it has been a while. I'd check there. :)
I don't wanna bother you, I'm searching and studying something. I thank you for your reply and your blog that was too useful to me to learn doing app with cordova. I thank you a lot
Hello,
This it what my mainactivity.java looks like:
package com.example.funcook;
import android.os.Bundle;
import org.apache.cordova.*;
import com.parse.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html"/> in config.xml
loadUrl(launchUrl);
Parse.initialize(this, "Mkf0EAJxxxxxxxxxxxxxxxxxxxpPIVD2EYw9vr3", "4wEURJ1WD4gEDmyyyyyyyyyyyyyyyy6cO6G8aQsE9");
PushService.subscribe(this, "", MainActivity.class);
}
}
And this is my androidmanifest
<manifest android:hardwareaccelerated="true" android:versioncode="1" android:versionname="0.0.1" package="com.example.funcook" xmlns:android="http://schemas.android.com/...">
<supports-screens android:anydensity="true" android:largescreens="true" android:normalscreens="true" android:resizeable="true" android:smallscreens="true" android:xlargescreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application android:hardwareaccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsrtl="true">
<activity android:configchanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchmode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowsoftinputmode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minsdkversion="14" android:targetsdkversion="22"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<service android:name="com.parse.PushService"/>
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.USER_PRESENT"/>
</intent-filter>
</receiver>
</manifest>
I wanted to see, as you recommend, if it still complies.
And this is the build log:
/Users/toniweb/Proyectos/cordova/mobile.funcook/platforms/android/src/com/example/funcook/MainActivity.java:35: error: cannot find symbol
PushService.subscribe(this, "", MainActivity.class);
^
symbol: method subscribe(MainActivity,String,Class<mainactivity>)
location: class PushService
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:compileDebugJava FAILED
FAILURE: Build failed with an exception.
Any idea what I'm missing?
There is a link towards the top of the article that points to an updated version, but even that one is about two years old.