Swift 3 - device tokens are now being parsed as '32BYTES'

前端 未结 11 2571
广开言路
广开言路 2020-12-13 01:27

I just updated from Xcode 7 to the 8 GM and amidst the Swift 3 compatibility issues I noticed that my device tokens have stopped working. They now only read \'32BYTES\'.

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 01:55

    This one wasn't stated as an official answer (saw it in a comment), but is what I ultimately did to get my token back in order.

    let tokenData = deviceToken as NSData
    let token = tokenData.description
    
    // remove any characters once you have token string if needed
    token = token.replacingOccurrences(of: " ", with: "")
    token = token.replacingOccurrences(of: "<", with: ""
    token = token.replacingOccurrences(of: ">", with: "")
    

提交回复
热议问题