19.11.2012 Views

Building Adobe AIR Applications

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CREACIÓN DE APLICACIONES DE ADOBE <strong>AIR</strong><br />

Desarrollo de aplicaciones de <strong>AIR</strong> para dispositivos móviles<br />

private var urlreq:URLRequest;<br />

private var urlLoad:URLLoader = new URLLoader();<br />

private var urlString:String;<br />

//When subscription is successful then only call the following code<br />

urlString = new String("https://go.urbanairship.com/api/device_tokens/" + e.tokenId);<br />

urlreq = new URLRequest(urlString);<br />

urlreq.authenticate = true;<br />

urlreq.method = URLRequestMethod.PUT;<br />

URLRequestDefaults.setLoginCredentialsForHost("go.urbanairship.com",<br />

"Application Key","Application Secret");<br />

urlLoad.load(urlreq);<br />

urlLoad.addEventListener(IOErrorEvent.IO_ERROR,iohandler);<br />

urlLoad.addEventListener(Event.COMPLETE,compHandler);<br />

urlLoad.addEventListener(HTTPStatusEvent.HTTP_STATUS,httpHandler);<br />

private function iohandler(e:IOErrorEvent):void{<br />

trace("\n In IOError handler" + e.errorID +" " +e.type);<br />

}<br />

private function compHandler(e:Event):void{<br />

trace("\n In Complete handler,"+"status: " +e.type + "\n");<br />

}<br />

private function httpHandler(e:HTTPStatusEvent):void{<br />

tt.appendText("\n in httpstatus handler,"+ "Status: " + e.status);<br />

}<br />

Seguidamente, puede enviar las notificaciones de prueba con las herramientas de Urban Airship.<br />

Certificados para el proveedor de notificaciones remotas<br />

Debe copiar el certificado SSL y la clave privada (generada previamente) en la ubicación adecuada del servidor del<br />

proveedor de notificaciones remotas. Lo habitual es combinar estos dos archivos en un único archivo .pem. Para ello,<br />

haga lo siguiente:<br />

1 Abra una ventana de Terminal.<br />

2 Cree un archivo .pem desde el certificado SSL escribiendo el siguiente comando:<br />

openssl x509 -in aps_developer_identity.cer -inform der -out TestPushDev.pem<br />

3 Cree un archivo .pem desde el archivo de clave privada (.p12) escribiendo el siguiente comando:<br />

openssl pkcs12 -nocerts -out TestPushPrivateKey.pem -in certificates.p12<br />

4 Combine los dos archivos .pem en uno solo escribiendo el siguiente comando:<br />

cat TestPushDev.pem TestPushPrivateKey.pem > FinalTestPush.pem<br />

5 Proporcione el archivo .pem combinado al proveedor del servidor cuando vaya a crear la aplicación push en el lado<br />

del servidor.<br />

Para obtener más información, consulte Instalación del certificado SSL y la clave en el servidor en el manual Apple<br />

Local and Push Notification Programming Guide.<br />

Última modificación 30/10/2012<br />

121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!