Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue resolving URL in attachment in iOS #968

Closed
zirho opened this issue Jan 19, 2024 · 1 comment
Closed

Issue resolving URL in attachment in iOS #968

zirho opened this issue Jan 19, 2024 · 1 comment

Comments

@zirho
Copy link

zirho commented Jan 19, 2024

Hey guys,

I am trying to reason about or understand better with an error I am getting when showing a notification with an image url on an iOS app.

I have an app that upload a file attaching to a post and show it on web/mobile.

From web, it works just fine all around. uploading/showing the image on notifications also works fine.
On mobile (iOS RN), it shows this error and image is not showing up.

Both image urls are publicly available (attached at the bottom) and you can open them just fine with browser / in-app as well.

The error message that I get is this

image

2024-01-18 22:43:21.246110-0800 TtoPet73[18769:26124771] NotifeeCore: An error occurred whilst trying to resolve an attachment {
    id = kZFIElNv0spdgpNaxURR;
    thumbnailHidden = 0;
    url = "https://storage.googleapis.com/ttopet-uploads/uploads/thumbnail_hello_755c44ce00/thumbnail_hello_755c44ce00.jpeg";
}: Error Domain=UNErrorDomain Code=101 "Unrecognized attachment file type" UserInfo={NSLocalizedDescription=Unrecognized attachment file type}

How I show notifications in RN

                const data = {
                  title: 'title',
                  body: 'body',
                  ios: {
                    attachments: [
                      {
                        url: 'https://storage.googleapis.com/ttopet-uploads/uploads/thumbnail_hello_755c44ce00/thumbnail_hello_755c44ce00.jpeg',
                      },
                    ],
                  },
                };

                notifee.displayNotification(data);

The images. They are from the same image files.

  1. Uploaded from mobile (not working for notification)
    https://storage.googleapis.com/ttopet-uploads/uploads/thumbnail_hello_755c44ce00/thumbnail_hello_755c44ce00.jpeg
  2. Uploaded from web (WORKS)
    https://storage.googleapis.com/ttopet-uploads/uploads/thumbnail_from_web_82e2a57d61/thumbnail_from_web_82e2a57d61.jpg

I looked at the notifiee code and spot the location that error is from.

https://github.com/invertase/notifee/blob/main/ios/NotifeeCore/NotifeeCoreUtil.m#L159-L167
But I don't know how to continue investigation from here.

Unrecognized attachment file type
And this could be related to type defined here.
I've tried some values from here but no luck.
https://developer.apple.com/documentation/usernotifications/unnotificationattachment#1682051

Any insights, thoughts or direction would be appreciated.

Thanks

@zirho
Copy link
Author

zirho commented Jan 19, 2024

Found the fix

https://notifee.app/react-native/reference/iosnotificationattachment#typehint

{
   url: 'some-url',
   typeHint: 'public.jpeg',
}

did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant