tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

How is `attachb64` supposed to be used? #2456

Closed vincentneo closed 1 year ago

vincentneo commented 1 year ago

When Telegram's Apple push notifications is received, if the message has an image attachment, there's a field with key of attachb64.

How is this supposed to be decoded? I assume base64 because 'b64', but it doesn't decode to anything meaningful.

levlam commented 1 year ago

It is used internally by TDLib when processPushNotification. You will not be able to decrypt it yourself.

vincentneo commented 1 year ago

According to #1599, processPushNotification isn't working for iOS, right? Or were there any recent changes for this?

levlam commented 1 year ago

If you can launch TDLib when a push notification is received, then you can use processPushNotification as in all other operating systems. Otherwise, you can't use attachb64.

vincentneo commented 1 year ago

I see. Will try that soon, thank you!

vincentneo commented 1 year ago

Nope not working, am getting error 400, "Receive empty loc_key", which suggests #1599 is still valid.

sample of a payload that I submitted:

{
    "from_id":"<redacted id>",
    "aps":{
        "thread-id":"<redacted id>",
        "mutable-content":1,
        "alert":{"title":"<redacted name>","body":"Test"},
        "category":"r",
        "sound":"0.m4a"},
    "msg_id":"<redacted id>"
}
vincentneo commented 1 year ago

If loc_key is manually provided by me, it will get error 400, "Can't find dialog_id"

levlam commented 1 year ago

Yes, processPushNotification isn't able to process iOS push notifications, because they are sent in a very specific format without a lot of data.

vincentneo commented 1 year ago

So there's basically no way at all when dealing with iOS push notifications to display a preview of the image in the notification?

levlam commented 1 year ago

Yes. Full MTProto implementation and support of the server-side API is required to decrypt and parse the field attachb64.

vincentneo commented 1 year ago

That’s unfortunate.

time to give up my adventure on this feature then…