If you are building your Android App using ActionScript APIs on Flash platform, integrating Push Notifications on it might eat up your time as it is not a straightforward task. Many people had asked us for a sample app/tutorial for the same after we released our ActionScript SDK. To address this, we have created a sample Flash Android application using App42 Action-Script API in which one can integrate App42 Push Notification in few easy steps. You can get started with this sample straightaway as described below.
# About Application
1. This application shows how can you integrate Push Notifications using App42 ActionScript API in Flash Android application.
2. How you can send Push Notifications using App42 Action-Script PushNotification API.
# Running Sample
1. Register with App42 platform.
2. Create an app once you are on the Quick start page after registration.
3. If you are already registered, login to AppHQ console and create an app from App Manager Tab.
4. To use PushNotification service in your application, open this link and create a new project here.
5. Click on services option in Google console and enable Google Cloud Messaging for Android service.
6. Click on API Access tab and create a new server key for your application with blank server information.
7. Go to AppHQ console and click on PushNotification and select Android Settings in Settings option.
8. Select your app and copy server key that is generated by using Google API console in step 6, and submit it.
9. Download the project from here and import it in your FlashBuilder.
10. Open App42Constants.as file of sample project and make following changes
Replace api-Key and secret-Key that you have received in step 2 or 3 at line number 5 and 6.
Replace project-no with your Google Project Number at line number 7.
Replace your user-id by which you want to register your application for PushNotification at line number 8.
11. Adding Android Native Extension.
Open Flex Build path and add app42Push.ane file and Native Extension in your Sample project if not added.
Open Flex Build packaging by selecting project properties, click on Google Android and select Native Extension and checked your Native Extension added in prior step.
11.Build your android application and install on your android device.
Test and verify PushNotification from AppHQ console
After registering for PushNotification go to AppHQ console and click on PushNotification and select application after selecting User tab.
Select desired user from the registered User-list and click on Send Push
Send appropriate message to user by clicking Send Button.
Send PushNotification to User using App42 ActionScript API : If you want to send PushNotification message using App42 ActionScript API, pass the userId, message, title and image which you want to show when a Push Notification is received by a device, written in App42FlashHome.mxml file.
private function onSendPushClick(event:MouseEvent):void
{
var jsonMessage:Object = new Object();
jsonMessage.title = "App42FlashPush";
jsonMessage.message = messageInput.text;
jsonMessage.image = "Your Image Url";
var message:String = JSON.stringify(jsonMessage);
App42API.buildPushNotificationService().sendPushMessageToUser(UserInput.text,message,
new App42FlashCallback());
}
For further design details and customization. Read this .
Video Tutorial
If you have any questions or need any further assistance, please feel free to write us at support@shephertz.com.
Leave A Reply