行deviceToken = deviceToken.replace(' ','').decode('hex')
正在崩潰我的腳本。 這是設備令牌:(用幾號改變)無法轉換爲十六進制 - 類型錯誤:找到非十六進制數字
deviceToken = '9cdcb815 d93e11ce 52baaf6c 14e27cc8 31d5ce62 2e51ce6d f75692c2 3617cadb'
第一個推送通知發出了罰款,所以我敢肯定,設備令牌是確定的,但第一個事件之後,我的這個錯誤:
['"INBOX" (UNSEEN 12)']
Sent Push alert.
Got an event!
['"INBOX" (UNSEEN 13)']
Exception in thread Thread-4:Exception in thread Thread-4:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 530, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 483, in run
self.__target(*self.__args, **self.__kwargs)
File "server.py", line 111, in idle
self.dosync()
File "server.py", line 118, in dosync
sendPushNotification(numUnseen)
File "server.py", line 54, in sendPushNotification
deviceToken = deviceToken.replace(' ','').decode('hex')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode
output = binascii.a2b_hex(input)
TypeError: Non-hexadecimal digit found
向我們展示你想轉換的字符串(雖然該錯誤信息是非常自我解釋,所有你需要的十六進制數字字符串中,並沒有這樣的) 。 (您是將實際設備令牌複製到腳本中,還是使用「XXXXX XXXX ...」進行嘗試?) – geoffspear 2013-04-29 15:03:11
設備令牌沒問題。我正在向我的iPhone發送第一個推送通知。錯誤發生在第一個事件之後。我將編輯該問題。 – Segev 2013-04-29 15:07:07
您正在用其字節替換全局deviceToken,然後在下次嘗試通過該函數再次執行該操作。這是不可重複的。 – geoffspear 2013-04-29 15:15:40