手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2012年07月18日的文章

apns 二三事

今天要說的還是推送,NND,這個推送這玩意,折騰死人
1、aps中是否只能有badge/alert/sound等參數?
答:不是,這個只是最基本的參數,可以有很多參數,但aps標記需要一定存在,其他參數可以自定義,比如:

JavaScript代码
  1. {  
  2.     "aps" : {  
  3.     },  
  4.     "acme2" : [ 5,  8 ]  
  5. }  

aps参数可以是空,但一定要有,上面这个可不是我杜撰的,这是官方的例子:http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW12

2、aps中的content-available是什么意思
答:这个是有特殊需要的时候才需要用,比如用来后台下载?说实话,我在官方没找到文档,反而在adobe找到一个小的介绍 :
第一个介绍:http://www.adobe.com/devnet/digitalpublishingsuite/articles/dps-push-notification.html

Table 3. Parameters for APNS messages

Property value description
alert <string> The text message to display to the user. No localization arguments are supported.
badge <number> If non-zero, it displays the number on the icon of the application. If zero, no number is displayed.
content-available 0 | 1 Non-zero indicates a Newsstand push message. The receipt of this will wake the viewer to begin a background download. See Notes.
sound "default" Only the default notification sound is supported.
productID <string> Product.

Notes about Newsstand background downloading

  1. Background downloads are limited to once every 24 hours, +/- 1 hour (or so). You can send as many alert messages you like, but only background downloading will be throttled.
  2. Background downloading will only happen over WiFi connections. If the user is on 3G and the push is received, the background download is lost.
  3. A valid subscription via Apple or direct entitlement (CDS, TCS, PCD, Dovetail, or other) must exist.
  4. Only the most recent folio will be background-downloaded. The user must be entitled to this content.
  5. Apple attempts a number of times to deliver the push payload. As such, the actual download may begin a significant amount of time after it was originally sent or scheduled.

用了content-available参数后,下一次接收一定是在24小时后。看上面的notes

还有一个介绍在这里:http://www.viggiosoft.com/blog/blog/2011/10/17/ios-newsstand-tutorial/,这篇博客很详细,还告诉你在APP中怎么设置,内容过长,我就不一一贴出来了。
它这么说:
The push notification message has the same syntax as standard push notifications with the only difference that the payload must contain the content-available key set to 1:

JavaScript代码
  1. {  
  2.   "aps":{  
  3.     "content-available":1,  
  4.         },  
  5.    "device_tokens": ["E9623F5CFDE92B40DA4AA90B97B70428BCD8FFCBA067BE17A6EF5102651E66E9"]  
  6. }  

There is one importation limitation related to the frequency of pushes: to limit the consumption of resources due to background downloading (which, by the way, we’ll happen only if the device is connected to a Wi-Fi network) Newsstand push notifications are coalesced and only one background download is permitted per day. For testing purposes you can remove this limit by setting an appropriate key in the user defaults (do this at startup in your App Delegate)
大小: 96.37 K
尺寸: 251 x 376
浏览: 1448 次
点击打开新窗口浏览全图

Tags: apns, apple

自动登录远程Linux服务器

SSH命令是用來連接遠程Linux服務器的,大多數時候,我們都是用的客戶端,好看又方便,還能保存密碼,但長久以往,居然我連密碼也忘了。。。悲催
所以,我在想,是否可以自動連接ssh服務器(不用客戶端)也不用記密碼?直接就完事?
公鈅?rsa public ?沒意思,那樣我還是記不住密碼,萬一被人一折騰,腫麼辦?

所以,找了一些資料,發現。。。sshpass真是一個好東西啊
最簡單的應用方法:sshpass -p 123456 ssh username@hostname
就可以了。
於是,比如 我現在的服務器,我新建 了一個腳本:neatstudio.com.sh,並且chmod +x ,然後在裏面就一行代碼:
sshpass -p 123456 ssh root@neatstudio.com
當然在執行這個文件之前,需要先ssh neatstudio.com一下。先保存完驗證的KEY,然後就可以執行./neatstudio.com.sh了。

於是,我密碼再也不會忘了,因為就在這個文件裏,這個可是明文的。。。。就算我設的再複雜也毛有關係了。。。輕輕鬆鬆

關於sshpass的下載,我這裏提供一個下載地址:sshpass-1.05.tar.gz

這個直接就是官方的版本,不過您為了安全,還是直接去sf下載吧。我這裏就權當是為我自己做一個備份。畢竟有時候sf是會被墻的

Tags: ssh