# [titanium] Apple Push Notification Services & Titanium SDK 2.0

- URL: https://justfly.idv.tw/titanium-apple-push-notification-services-titanium-sdk-2-0/
- 日期: 2012-04-27
- 分類: WEB&amp;RIA
- 標籤: ACS, app, free, iphone, php, Titanium

https://justfly.idv.tw/wp-content/uploads/2012/04/Apple-Push-Notification-Services.png在Titanium SDK 2.0之前，要[在Titanium實現「Apple Push Notification Service」](https://justfly.idv.tw/2012/04/26/Just_1195.html)是一件很麻煩的事（我還沒有成功＠＠），但是，前幾天Titanium sdk升級到2.0.1.GA2後，一切就可愛了很多。

首先可以更新一下[KitchenSink](https://github.com/appcelerator/KitchenSink)，會發現多了不少的範例檔案。其中就包括push_notification.js。原來是多了[Titanium.Network.registerForPushNotifications](http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Network-method-registerForPushNotifications)這個api可以用！

找一個喜歡的地方把程式碼貼上去後，可以在畫面上看到「Attempting to register with Apple for Push Notifications…」這一行字。所以，就來跟APNS註冊一下app吧！！

不過其實註冊的文章很多人都寫過了，[這一篇](http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12)我覺得還蠻詳細的，可以參考看看，一步一步照做就可以實現Apple Push Notification Services了。

本來我是打算用[appcelerator的ACS](https://my.appcelerator.com/apps/titanium)來push的，只是，我不懂要怎麼在ACS註冊客戶端，所以在push_notification的畫面就一直卡在「You currently have 0 iOS clients, 0 Android clients subscribed to push notifications.」這個訊息＠＠。好在[這一篇](http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12)連push用的php都幫我們準備好了，看看他的原始碼也不難。

```

```

所以如果我們可以在titanium中在用Titanium.Network.createHTTPClient呼叫的話，應該可以多出更多的用法了吧～
