Developing an iOS App using ActionScript APIs on Flash platform along with the integration of Push Notification is a time consuming process and we understand, your time is precious. Therefore, the main objective of this post is to make the process easier and more understandable for developers who want to create an Push enabled App for iPhone using Flash. For your convenience, we are showcasing a PushSample application using App42 Action-Script API. Here, we can integrate App42 Push Notification in just few minutes.
Topics to be Covered
1. How to integrate Push Notification using App42 ActionScript API in Flash iOS application?
2. How to 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. First you have to create a certificate from iOS Dev Center and follow the simple steps mentioned in Prerequisite Setup.
5. Download the project from here and import it in your FlashBuilder or if, you want to create your own project, then create new ActionScript Mobile Project in MobileSelect tab. Post that select Apple iOS. Then, click Finish
6. Information will be added in AIR app-descriptor XML, which is specific to iOS. (Note: It will change when you make a new project)
Bundle ID // add your Apple Bundle ID that you have received in step 4
UIDeviceFamily
1
2
UIStatusBarStyle
UIStatusBarStyleBlackOpaque
UIRequiresPersistentWiFi
YES
]]>
aps-environment
development
]]>
high
7. Open Constant.as file of sample project and make following changes
Replace api-Key and secret-Key that you have received in step 2 or 3.
Replace your user-name by which you want to register your application for PushNotification.
8. You can use the Flash Builder – File | Export | Release Build (under Flash Builder in the Export dialog) option or choose Direct Export Release Build as shown in the screen shot
9. Add iOS Packaging File
a) Select Project, Application, Target Platform
b) Set the Packaging Setting, choose Digital Signature Set for all the fields that are received in Step 4. Now, click Finish. It will take a few seconds to make
.ipa in your project folder
10. Select this .ipa file and .mobileprovision drop in iTunes. Then, install it in your mobile.
Test and Verify PushNotification from AppHQ Console
1 Click Store Token button that stores the device token of the user that you had passed in step 7
2 After registering for PushNotification, go to AppHQ console and click on PushNotification. Select Users and then select application
3 Select desired user from the registered User-list and click on Send Push
4 Send appropriate message to the user by choosing Send button
Send PushNotification to User using App42 ActionScript API :
1. Click Store Token button that stores the device token of the user that you had passed in step 7
public function storeDeviceToken_click(e:MouseEvent):void
{
outputBtn.text = "";
pushNotificationService.storeDeviceToken(Constant.userName, deviceToken, DeviceType.iOS , new app42StorePushCallBack());
}
//Callback Class
class app42StorePushCallBack implements App42CallBack {
public function onSuccess(response:Object):void
{
outputBtn.appendText("\n PushNotification");
var pushNotification:PushNotification = PushNotification(response);
outputBtn.appendText("\n PushNotification success is : "+pushNotification)
outputBtn.appendText("\n User Name : "+pushNotification.getUserName());
outputBtn.appendText("\n DeviceToken :"+pushNotification.getDeviceToken());
outputBtn.appendText("\n Device Type : "+pushNotification .getType());
}
public function onException(exception:App42Exception):void
{
outputBtn.appendText ( "\n Exception is : " + exception);
}
}
2. Enter Message and press Send Message button. The response you get will be printed on output console screen.
public function sendMessage_click(e:MouseEvent):void
{
outputBtn.text = "";
pushNotificationService.sendPushMessageToUser(Constant.userName, headingTextField , new app42PushCallBack());
}
//Callback Class
class app42PushCallBack implements App42CallBack
{
public function onSuccess(response:Object):void
{
outputBtn.appendText("\n PushNotification");
var pushNotification:PushNotification = PushNotification(response);
outputBtn.appendText("\n PushNotification success is : "+pushNotification)
outputBtn.appendText("\n User Name : "+pushNotification.getUserName());
outputBtn.appendText("\n Expiry is " + pushNotification.getExpiry());
outputBtn.appendText("\n Message is " + pushNotification.getMessage());
}
public function onException(exception:App42Exception):void
{
outputBtn.appendText ( "\n Exception is : " + exception);
}
}
Note: If your App is open then, the Message is shown in Output Console.
We would love to hear your feedback and suggestions about this sample. If you have questions or need any further assistance, please write to us at support@shephertz.com
Leave A Reply