Implementation Guide

advertisement
Create a New Google API Project with GCM
To use Google Cloud Messaging (GCM) in your application(s), first you need to create a new project in
the Google APIs console and enable it to use the GCM service.
>> Open the Google APIs Console page.
>> Click Create project. Google will create a Project Number for you. This Project Number is what you will
include in your application.
>> Click on the Services tab and enable Google Cloud Messaging for Android.
>> Click on the API Access tab and click on the "Create Server Key" button. Please don't include any IP
address restrictions. Hit the "Create" button and take note of the resulting key as it will be used later
when you register your Android application with MessageMissile.
Register your Android App with Message Missile
>> Create a free account at http://messagemissile.com/message_missile/index.php
>> Register your app with Message Missile and get the App Key.
Implement the MessageMissile Android SDK
within your App
a.
b.
c.
d.
e.
f.
g.
Import MessageMissile Library project.
Select your project.
Right click->properties
Choose "Android"
Click on add
Select the MessageMicile project.
Click Ok.
>> Modify the 'AndroidManifest.xml' file:
Android Version: Set the minimum Android SDK version to '8' (Android 2.2) or higher. The Message
Missile Android SDK will not work with previous versions.
<uses-sdk android:minSdkVersion="8" />
Permissions: The following permissions are needed for the SDK to work properly (These are positioned
as children of the <manifest> node). Replace the occurrences of YOUR_APP_PACKAGE_NAME with
your application package name.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="YOUR_APP_PACKAGE_NAME.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="YOUR_APP_PACKAGE_NAME.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_GPS"/>
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
Application Components: Add the following xml to the <application> node. Replace the occurrence of
YOUR_APP_PACKAGE_NAME with your application package name:
<activity
android:name="YOUR_APP_PACKAGE_NAME.RichNotification"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.RichNotification" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver
android:name="com.infl.messagemicile.PushLibraryBroadcastReceiver"
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="YOUR_APP_PACKAGE_NAME" />
</intent-filter>
</receiver>
<service android:name="com.infl.messagemicile.GCMIntentService" />
<service android:name="com.infl.messagemicile.MessageMissileRService" />
Edit your Main activity: In your main activity (the activity that is launched when the app is first open) you
need to do the following:
Add the following import:
import com.infl.messagemicile.SdkInit;
Then call init method of SdkInit in the activity onStart method:
private static final String MESSAGE_MISSILE_APP_KEY = "YOUR_
MESSAGE_MISSILE_APP_KEY ";
private static final String PROJECT_NUM = "YOUR _PROJECT_NUM ";
SdkInit sdk=new SdkInit();
sdk.init(this, MESSAGE_MISSILE_APP_KEY, PROJECT_NUM);
Change "YOUR_ MESSAGE_MISSILE_APP_KEY " with your Message Missile appKey
and " YOUR _PROJECT_NUM " with your Google API Project Number you created
earlier.
sdk.init() will start the registration process with Message Missile and GCM and then it
will ensure that the Message Missile SDK component is running. Here's an example:
public class MainActivity extends Activity {
private static final String MESSAGE_MISSILE_APP_KEY = " YOUR_
MESSAGE_MISSILE_APP_KEY ";
private static final String PROJECT_NUM = " YOUR _PROJECT_NUM ";
@Override
protected void onStart() {
super.onStart();
SdkInit sdk=new SdkInit();
sdk.init(this, MESSAGE_MISSILE_APP_KEY, PROJECT_NUM);
}
}
Copy file RichNotification.java(find in sdk Zip folder) in the src folder of your
project.
Copy file rich_notification.xml (find in sdk Zip folder) in the layout folder of your
project.
Run your project and enjoy……….
Download