I had implemented Push Notification [ Using Urban Air Ship] application in Android,
with the help of the steps shown in the Urbran Air Ship documentation
http://urbanairship.com/docs/android_client.html,
It works in a nice and fine manner,and also i got notifcation, when my feed is updated. Here's the step what had done.
Step1: Create a Account in Urban Air Ship, https://go.urbanairship.com/
Step2: Download android_push.jar from here https://github.com/urbanairship/android-push-library/downloads
Step3: register the receiver in AndroidManifest.xml before closing your closing your application tag file as shown below
<application>
:
:
:
<receiver android:name="com.urbanairship.push.IntentReceiver">
<intent-filter>
<action android:name="com.urbanairship.airmail.END_REGISTER"></action>
<action android:name="com.urbanairship.airmail.ACCEPT_PUSH"></action>
<action android:name="com.urbanairship.airmail.NOTIFY"></action>
</intent-filter>
</receiver>
</application>
Step 4: Login in your Account, Register Your Application in their site. For that Click Apps option in your account.
Step5: After Clicking the Apps the icon, you are able to see Add your Application Option as shown in the following diagram
Step6: Enter your App Name and Click Push Notification Support, then fed your package name. and Click create your App Button, A new Window will give you,Application Key.
Step 7: Create a file called ua.properties under raw folder which is under in res folder, i.e., res/raw/ua.properties file
Step8: Fed the Application Key which you got after App registartion in Urban AirShip and also finger print of your App in ua.properties file as shown below.
debug=true debug.app_key=j9kRTqaCRR-E0xf-iu2XEA
production.app_key=9D:54:23:3F:F3:25:AB:0B:DC:8E:D9:C8:B3:F4:96:F9
Step 9: Create a Application Class as shown Below
import com.urbanairship.push.APIDReceiver; import
com.urbanairship.push.AirMail; import
com.urbanairship.push.PushReceiver;
import android.app.Application; import android.content.Intent; import
android.util.Log;
public class PushNotification extends Application { public void
onCreate(){ AirMail am = AirMail.getInstance(); am.acceptPush(this,
new PushReceiver() { @Override public void onReceive(String message,
String payload){ Log.d("push", "Got message '" + message +"' and
payload '" + payload + "'"); }
@Override public void onClick(String message, String payload){
Log.d("push", "User clicked the notification, got message and payload:
"
+ message + ", " + payload); /* In this example, we fire up our MainActivity class when the
* user clicks the Status Bar Notification. Note that we *must*
* use the flag Intent.FLAG_ACTIVITY_NEW_TASK to start a new
* activity because this callback is fired from within a
* BroadcastReceiver.
**/ Intent intent = new Intent("android.intent.action.MAIN"); intent.setClass(PushNotification.this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PushNotification.this.startActivity(intent); } });
am.setAPIDReceiver(this, new APIDReceiver() { @Override public void
onReceive(String apid, boolean valid){ if(valid){ Log.d("push", "Got
apid: " + apid); } else { Log.d("push", "Application registration
invalid!"); } }
@Override public void onAirMailInstallRefusal() {
Rss_Feed_Grid.register = false; Log.d("push", "AirMail Install
Refused!"); } }); } }
Step 10: Check the following registration code in your Activity
protected static boolean register = true;
if(register){ AirMail am = AirMail.getInstance(); am.register(this); }
Step 11:
Update Your Manifest in order to register your application
<application android:icon="@drawable/icon"
android:label="@string/app_name" android:name=".PushNotification">
Step12: Now Click Push Notification and then click feed Button in Urbran Air Ship, then fed url which is to be monitored
That's it..
Refer my blog for more information
http://sankarganesh-info-exchange.blogspot.sg/p/push-notification-in-android-using.html