Since we've been using Pushwoosh there have been 2 occasions where we have needed to get hold of their support team. Normally when dealing with international companies one sends a mail, yet we don't have much faith that our problems will be attended to. On both occasions where we required support assistance we were contacted by members of the Pushwoosh support team within a couple of hours and our issues were resolved. The efficient service did not however end there as we received follow up emails after everything had been resolved to ensure that our account was working correctly and that we were happy with what had been done.

We have been so impressed by the service offered by the Pushwoosh team. It's a pleasure to deal with them - nothing is ever too much hassle to sort out.

Thanks again to Dmitry and the Pushwoosh team for your ongoing incredible support.

Raedene Reardon

Co-founder & Managing Member

Floodlight Studios

READ TESTIMONIAL

Native Android SDK

Download SDK Sample Project

Due to compatibility with Android 4 please make sure you are using at least 11 version of the Android API.

The SDK will run on older devices.

NOTE: Push notifications work on Android Emulator. You have to have Google Play account set up on the Emulator.

To integrate Pushwoosh into your Android application you need to do simple following steps:

1. Get SDK (Pushwoosh.jar) from the link above

2. Place it in the libs folder of your Android project.

In 99% you don’t have to do this step as adding Pushwoosh.jar to libs folder adds it to classpath of your project automatically. But if something goes wrong you might need to add it manually:

For Eclipse: http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)

For IDEA: http://stackoverflow.com/questions/1051640/correct-way-to-add-lib-jar-to-an-intellij-idea-project

3.a In the main activity add the following receivers:

	//Registration receiver
	BroadcastReceiver mBroadcastReceiver = new RegisterBroadcastReceiver()
	{
		@Override
		public void onRegisterActionReceive(Context context, Intent intent)
		{
			checkMessage(intent);
		}
	};
	
	//Push message receiver
	private BroadcastReceiver mReceiver = new BasePushMessageReceiver()
	{
		@Override
		protected void onMessageReceive(Intent intent)
		{
			//JSON_DATA_KEY contains JSON payload of push notification.
			showMessage("push message is " + intent.getExtras().getString(JSON_DATA_KEY));
		}
	};

	//Registration of the receivers
	public void registerReceivers()
	{
		IntentFilter intentFilter = new IntentFilter(getPackageName() + ".action.PUSH_MESSAGE_RECEIVE");

		registerReceiver(mReceiver, intentFilter);
		
		registerReceiver(mBroadcastReceiver, new IntentFilter(getPackageName() + "." + PushManager.REGISTER_BROAD_CAST_ACTION));		
	}

	public void unregisterReceivers()
	{
		//Unregister receivers on pause
		try
		{
			unregisterReceiver(mReceiver);
		}
		catch (Exception e)
		{
			// pass.
		}
		
		try
		{
			unregisterReceiver(mBroadcastReceiver);
		}
		catch (Exception e)
		{
			//pass through
		}
	}
3.b Manage receivers registration in the onPause/onResume functions
	@Override
	public void onResume()
	{
		super.onResume();
		
		//Re-register receivers on resume
		registerReceivers();
	}

	@Override
	public void onPause()
	{
		super.onPause();

		//Unregister receivers on pause
		unregisterReceivers();
	}
3.c In the main activity initialize the PushManager and register receivers:
 @Override
   public void onCreate(Bundle savedInstanceState)
   {
       super.onCreate(savedInstanceState);

       //Register receivers for push notifications
       registerReceivers();

       //Create and start push manager
       PushManager pushManager = PushManager.getInstance(this);
       
       //Start push manager, this will count app open for Pushwoosh stats as well
       try {
              pushManager.onStartup(this);
       }
       catch(Exception e)
       {
              //push notifications are not available or AndroidManifest.xml is not configured properly
       }
       
       //Register for push!
       pushManager.registerForPushNotifications();

       checkMessage(getIntent());

       // other code
   }

4. In AndroidManifest.xml manifest add the following lines under application tag. The GCM Project Number is a number, but make sure you prefix it with the letter “A”.

Example:
<meta-data android:name="PW_APPID" android:value="4F0C807E51EC77.93591449" />
<meta-data android:name="PW_PROJECT_ID" android:value="A60756016005" />

Where:

PW_APPID – Pushwoosh Application ID

PW_PROJECT_ID – Project Number you receive from Google GCM

(see more: http://developer.android.com/guide/google/gcm/index.html and http://developer.android.com/guide/google/gcm/gs.html)

Project ID is a number but make sure you prefix it with the letter “A”

5. In the main activity create the following method:

    private void checkMessage(Intent intent)
    {
        if (null != intent)
        {
            if (intent.hasExtra(PushManager.PUSH_RECEIVE_EVENT))
            {
                showMessage("push message is " + intent.getExtras().getString(PushManager.PUSH_RECEIVE_EVENT));
            }
            else if (intent.hasExtra(PushManager.REGISTER_EVENT))
            {
                showMessage("register");
            }
            else if (intent.hasExtra(PushManager.UNREGISTER_EVENT))
            {
                showMessage("unregister");
            }
            else if (intent.hasExtra(PushManager.REGISTER_ERROR_EVENT))
            {
                showMessage("register error");
            }
            else if (intent.hasExtra(PushManager.UNREGISTER_ERROR_EVENT))
            {
                showMessage("unregister error");
            }

            resetIntentValues();
        }
    }

	/**
	 * Will check main Activity intent and if it contains any PushWoosh data, will clear it
	 */
	private void resetIntentValues()
	{
		Intent mainAppIntent = getIntent();

		if (mainAppIntent.hasExtra(PushManager.PUSH_RECEIVE_EVENT))
		{
			mainAppIntent.removeExtra(PushManager.PUSH_RECEIVE_EVENT);
		}
		else if (mainAppIntent.hasExtra(PushManager.REGISTER_EVENT))
		{
			mainAppIntent.removeExtra(PushManager.REGISTER_EVENT);
		}
		else if (mainAppIntent.hasExtra(PushManager.UNREGISTER_EVENT))
		{
			mainAppIntent.removeExtra(PushManager.UNREGISTER_EVENT);
		}
		else if (mainAppIntent.hasExtra(PushManager.REGISTER_ERROR_EVENT))
		{
			mainAppIntent.removeExtra(PushManager.REGISTER_ERROR_EVENT);
		}
		else if (mainAppIntent.hasExtra(PushManager.UNREGISTER_ERROR_EVENT))
		{
			mainAppIntent.removeExtra(PushManager.UNREGISTER_ERROR_EVENT);
		}

		setIntent(mainAppIntent);
	}

    private void showMessage(String message)
    {
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    }

Also call this method from onNewIntent as well.

   @Override
   protected void onNewIntent(Intent intent)
   {
       super.onNewIntent(intent);
       setIntent(intent);

       checkMessage(intent);
   }

In the AndroidManifest.xml make the following changes for this activity. Replace PACKAGE_NAME with the package name for your application.

       <activity android:name="YourStartActivity"
                 android:launchMode="singleTop"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="PACKAGE_NAME.MESSAGE"/>
               <category android:name="android.intent.category.DEFAULT"/>
           </intent-filter>
           <intent-filter>
               <action android:name="android.intent.action.MAIN"/>
               <category android:name="android.intent.category.LAUNCHER"/>
           </intent-filter>
       </activity>

6. Add the following changes in your AndroidManifest.xml under manifest tag. Replace PACKAGE_NAME with the package name for your application.

You can find your package name in the AndroidManifest.xml under the manifest tag in the very top of the file.
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <!--library-->
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <!-- GCM connects to Google Services. -->
    <uses-permission android:name="android.permission.INTERNET"/>

    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>

    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

    <!--
     Creates a custom permission so only this app can receive its messages.

     NOTE: the permission *must* be called PACKAGE.permission.C2D_MESSAGE,
           where PACKAGE is the application's package name.
    -->
    <permission
            android:name="PACKAGE_NAME.permission.C2D_MESSAGE"
            android:protectionLevel="signature"/>
    <uses-permission
            android:name="PACKAGE_NAME.permission.C2D_MESSAGE"/>

    <!-- This app has permission to register and receive data message. -->
    <uses-permission
            android:name="com.google.android.c2dm.permission.RECEIVE"/>

    <!-- GCM requires Android SDK version 2.2 (API level 8) or above. -->
    <!-- The targetSdkVersion is optional, but it's always a good practice
         to target higher versions. -->
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>

7. Add the following changes in your AndroidManifest.xml under application tag. Replace PACKAGE_NAME with the package name for your application.

You can find your package name in the AndroidManifest.xml under the manifest tag in the very top of the file.
        <activity android:name="com.arellomobile.android.push.PushWebview"/>

        <activity android:name="com.arellomobile.android.push.MessageActivity"/>

        <activity android:name="com.arellomobile.android.push.PushHandlerActivity"/>

        <!--
          BroadcastReceiver that will receive intents from GCM
          services and handle them to the custom IntentService.

          The com.google.android.c2dm.permission.SEND permission is necessary
          so only GCM services can send data messages for the app.
        -->
        <receiver
                android:name="com.google.android.gcm.GCMBroadcastReceiver"
                android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <!-- Receives the actual messages. -->
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <!-- Receives the registration id. -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
                <category android:name="PACKAGE_NAME"/>
            </intent-filter>
        </receiver>

        <!--
          Application-specific subclass of PushGCMIntentService that will
          handle received messages.
        -->
        <service android:name="com.arellomobile.android.push.PushGCMIntentService"/>

If you need to handle custom notifications from your server, you should create a class extended from com.arellomobile.android.push.PushGCMIntentService, and include this custom intent service under the “PW_PUSH_SERVICE” tag in your manifest file.

Ex.: In your manifest you have to substitute the

<service android:name="com.arellomobile.android.push.PushGCMIntentService"/>
with
<service android:name=".CustomPushService" />
<meta-data android:name="PW_PUSH_SERVICE" android:value="PACKAGE_NAME.CustomPushService" />


If you would like to use Geo Push Notifications, add the following service to your manifest file:

        <!--
          Service for sending location updates
        -->
        <service android:name="com.arellomobile.android.push.GeoLocationService"/>

You should also call startTrackingGeoPushes() for your PushManager object. Please see our SDK API here.

That’s it!

Note: If your device is connected to the Internet via WiFi, and messages don’t get through to the device, please make sure GCM ports are not blocked by your firewall.

The device accesses the GCM servers on ports 5228-5230. If your organization has a firewall that restricts the traffic to or from the Internet, you’ll need to configure it to allow connectivity with GCM. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. GCM doesn’t provide specific IPs. It changes IPs frequently.


Push Notifications SDK API: