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

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
浏览: 1791 次
点击打开新窗口浏览全图

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

关于APNS的一件挫事

APNS 这玩意啊。关于它曾经转载过N篇文章:

不过自己在實際使用中,也還是遇到了問題。

在測試的時候,我連接apns服務器時,發一條推送就斷開,導致我發送上萬條消息的時候需要幾個小時。我就納悶了,如果大家都這樣,那豈不是那些大網站都要崩潰?這時候,有兩位朋友告訴我,不要斷開,用長鏈接。。。於是乎我重改了代碼,然後就看到消息發送的時候刷刷刷的就出去了。心裏還是非常開心的。

但偶爾還是會有發送失敗的情況出現,所以我做了一點處理,如果取回來的代碼不正確,我會一直重發,直到正確。當然,每次發完後,用usleep,休息了10ms,避免數據過度發送。當然每1000條推送後,我會斷開一下鏈接,再重新鏈接。以防萬一

說白了,還是糾結。

Tags: apns

在幾年前的時候,有人問,這世界上最遠的距離是什麼。有人回復:這世界上最遠的距離是,明明兩人就在身邊,卻不知道我愛你
還有人回復:這世界上最遠的距離不是他和她之間的距離,而是電信和網通
現在,這世界上沒有最遠的距離 ,只有一堵墻

傳說中,只要鋤頭揮的好,沒有墻角挖不倒,於是我們就有了各種各樣的軟件和或方法
1、有VPS的同學,開始裝VPN,有VPS但是不能裝VPN的同學,開始用Ssh -d 翻墻
2、沒有VPS的同學,開始買 VPN或者ssh -d
3、沒錢,但懂網絡的,開始用在線代理
4、沒錢,不懂網絡的,開始在朋友的介紹下,用opendns或者洋蔥頭,或者XX門

突然想起某阿姨和我說的,多听听其他声音也好,于是。如果你既没钱,也不懂网络 ,你可以尝试找某阿姨要一张能上网的光盘就OK了。那段文字来自:随便说说

count_chars的另类作用

count_chars表面上是計算char出現的次數,但事實上對中文支持明顯是不好的。
所以,它還有另外一個作用,即count_chars($str,4);
看好第二個參數哦。當這個參數是4時,會返回所有的会用作计算的字符串:

XML/HTML代码
  1.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`defghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™šœžŸ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¹»¼¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãæçèéêëìíîïðñòóôõö÷øùúûüýþÿ  

嗯,因此这也算是一个小技巧啦。