Permalink
Browse files

added isSupported function

  • Loading branch information...
1 parent f71bab4 commit 24c4620d8f031c658a6000e7ec7c52b9459db3e5 @pwalczyszyn committed Oct 9, 2011
Binary file not shown.
@@ -255,8 +255,9 @@
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
- <extensions>
+
+
+<extensions>
<extensionID>com.riaspace.c2dm</extensionID>
</extensions>
-
</application>
@@ -41,18 +41,21 @@
protected function view_creationCompleteHandler(event:FlexEvent):void
{
- // Using C2DM ANE to register application in C2DM service
- c2dm = new C2DM;
- // Listening for un/registered, error events
- c2dm.addEventListener(C2DMRegistrationEvent.REGISTERED, onRegistered);
- c2dm.addEventListener(C2DMRegistrationEvent.UNREGISTERED, onUnregistered);
- c2dm.addEventListener(C2DMErrorEvent.ERROR, onError);
-
- // Checking if application was already registered in C2DM service
- var registrationId:String = persistence.getProperty("registration_id") as String;
- registered = registrationId != null;
-
- trace("Current registration id:", registrationId);
+ if (C2DM.isSupported)
+ {
+ // Using C2DM ANE to register application in C2DM service
+ c2dm = new C2DM;
+ // Listening for un/registered, error events
+ c2dm.addEventListener(C2DMRegistrationEvent.REGISTERED, onRegistered);
+ c2dm.addEventListener(C2DMRegistrationEvent.UNREGISTERED, onUnregistered);
+ c2dm.addEventListener(C2DMErrorEvent.ERROR, onError);
+
+ // Checking if application was already registered in C2DM service
+ var registrationId:String = persistence.getProperty("registration_id") as String;
+ registered = registrationId != null;
+
+ trace("Current registration id:", registrationId);
+ }
}
private function onError(event:C2DMErrorEvent):void
@@ -101,9 +104,9 @@
<s:VGroup verticalCenter="0" horizontalCenter="0" gap="20">
<s:Button id="btnRegister" label="Register" click="btnRegister_clickHandler(event)"
- enabled="{!registered}" width="150" />
+ enabled="{!registered &amp;&amp; C2DM.isSupported}" width="150" />
<s:Button id="btnUnregister" label="Unregister" click="btnUnregister_clickHandler(event)"
- enabled="{registered}" width="150" />
+ enabled="{registered &amp;&amp; C2DM.isSupported}" width="150" />
</s:VGroup>
</s:View>
View
Binary file not shown.
View
@@ -1,6 +1,6 @@
unzip -o bin/as3c2dm.swc -x catalog.xml
-/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adt -package -storetype pkcs12 -keystore ~/Projects/cert/my-android-cert.pfx -target ane as3c2dm.ane src/extension.xml -swc bin/as3c2dm.swc -platform Android-ARM library.swf as3c2dm.jar
+/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adt -package -storetype pkcs12 -keystore ~/Projects/cert/my-android-cert.pfx -target ane as3c2dm.ane src/extension.xml -swc bin/as3c2dm.swc -platform default library.swf -platform Android-ARM library.swf as3c2dm.jar
cp as3c2dm.ane ../as3c2dm-example/extensions/
@@ -24,6 +24,7 @@ package com.riaspace.c2dm
import flash.events.EventDispatcher;
import flash.events.StatusEvent;
import flash.external.ExtensionContext;
+ import flash.system.Capabilities;
[Event(name="error", type="com.riaspace.c2dm.events.C2DMErrorEvent")]
[Event(name="registered", type="com.riaspace.c2dm.events.C2DMRegistrationEvent")]
@@ -39,6 +40,12 @@ package com.riaspace.c2dm
extContext.addEventListener(StatusEvent.STATUS, onStatus);
}
+ public static function get isSupported():Boolean
+ {
+ var manufacturer:String = Capabilities.manufacturer.toLowerCase();
+ return manufacturer.indexOf("android") >= 0;
+ }
+
public function register(emailOfSender:String):void
{
extContext.call("register", emailOfSender);
View
@@ -1,19 +1,31 @@
<!--
- ADOBE SYSTEMS INCORPORATED
- Copyright 2011 Adobe Systems Incorporated
- All Rights Reserved.
-
- NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
- terms of the Adobe license agreement accompanying it. If you have received this file from a
- source other than Adobe, then your use, modification, or distribution of it requires the prior
- written permission of Adobe.
+//////////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright 2011 Piotr Walczyszyn (http://riaspace.com | @pwalczyszyn)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//////////////////////////////////////////////////////////////////////////////////////
-->
<extension xmlns="http://ns.adobe.com/air/extension/2.5">
<id>com.riaspace.c2dm</id>
<versionNumber>1</versionNumber>
<platforms>
+ <platform name="default">
+ <applicationDeployment />
+ </platform>
<platform name="Android-ARM">
<applicationDeployment>
<nativeLibrary>as3c2dm.jar</nativeLibrary>

0 comments on commit 24c4620

Please sign in to comment.