iOS本地推送自定义Python服务器:Payload格式与SSL错误求助
自定义Local Push Connectivity Python服务器的Payload格式与SSL问题解决
问题背景
参考Apple官方Local Push Connectivity示例实现iOS本地推送功能后,NEAppPushProvider可正常拦截SimplePushServer发送的消息。现需开发一款无网络场景下可用的自定义Python服务器,向iOS应用推送通知,希望了解所需的推送Payload格式。
当前Python服务器代码
import socket HOST = "192.168.1.7" # Standard loopback interface address (localhost) PORT = 5061 # Port to listen on (non-privileged ports are > 1023) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() conn, addr = s.accept() with conn: print(f"Connected by {addr}") while True: data = conn.recv(1024) if not data: break conn.sendall(data)
Xcode错误日志
2023-06-08 17:11:36.199712+0200 SimplePush[2512:1251903] [boringssl] boringssl_context_handle_fatal_alert(1991) [C1:6][0x1068080f0] write alert, level: fatal, description: unexpected_message 2023-06-08 17:11:36.199891+0200 SimplePush[2512:1251903] [boringssl] boringssl_context_error_print(1981) [C1:6][0x1068080f0] Error: 4405097624:error:100000df:SSL routines:OPENSSL_internal:UNEXPECTED_MESSAGE:/Library/Caches/com.apple.xbs/Sources/boringssl/ssl/handshake_client.cc:728: 2023-06-08 17:11:36.204140+0200 SimplePush[2512:1251903] [boringssl] boringssl_session_handshake_incomplete(88) [C1:6][0x1068080f0] SSL library error 2023-06-08 17:11:36.204211+0200 SimplePush[2512:1251903] [boringssl] boringssl_session_handshake_error_print(43) [C1:6][0x1068080f0] Error: 4405097624:error:100000df:SSL routines:OPENSSL_internal:UNEXPECTED_MESSAGE:/Library/Caches/com.apple.xbs/Sources/boringssl/ssl/handshake_client.cc:728: 2023-06-08 17:11:36.204262+0200 SimplePush[2512:1251903] [boringssl] nw_protocol_boringssl_handshake_negotiate_proceed(771) [C1:6][0x1068080f0] handshake failed at state 12288: not completed 2023-06-08 17:11:36.205180+0200 SimplePush[2512:1251903] [Debug] Control Channel: Connection State - waiting(-9856: peer rejected unexpected message) 2023-06-08 17:11:36.205298+0200 SimplePush[2512:1251903] [Debug] Control Channel: -9856: peer rejected unexpected message 2023-06-08 17:11:36.205386+0200 SimplePush[2512:1251903] [Debug] Control Channel: TLS Error Code - -9856
Python控制台输出
python3 test2.py Connected by ('192.168.1.8', 55165) 随后连接关闭。
已在info.plist中添加NSExceptionAllowsInsecureHTTPLoads,恳请技术帮助。
内容的提问来源于stack exchange,提问作者tamtoum1987
相关产品推荐
相关产品推荐

