iPhone Push Notification Character Limit

前端 未结 3 1288
死守一世寂寞
死守一世寂寞 2020-12-13 18:48

I\'m brand new to IOS push notifications. I have been reading about them and can\'t seem to find this information anywhere. I have read that the size limit on a push notif

3条回答
  •  执念已碎
    2020-12-13 19:06

    In my APNS test in the production environment, up to 33 Chinese characters and 2 custom properties of 13 bytes could be sent successfully.

    {
    
        "aps": {
            "alert": "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三",
            "badge": 12,
        }
        "t": 123,
        "v": "1234567890"
    }
    

    The above payload length was 158 bytes if saved as file, not counting the space characters. Each Chinese character was counted as 3 bytes (I confirmed that by removing all of them to see the size change).

    As official document mentioned, the 256-bytes limitation does not include the device token , but I believe there are other characters APNS are counted in, such as 'sound' and 'content-available' even if you do not use explicitly.

    So be careful not to be 'too long', especially when using custom payloads. Be aware that APNS development environment does not limit the payload length. Your test pass while using development environment, but may fail in product. Do not take it as certain.

提交回复
热议问题