Open trajano opened 1 week ago
seems to be well supported at least in theory
as long as it is a local file of supported type and within size limits (https://developer.apple.com/documentation/usernotifications/unnotificationattachment#1682051)
I assume it works if the file is in the bundle? it's just downloading a local file first then trying to display it that is not working?
Adding instrumentation logs here and running from Xcode may be instructive https://github.com/invertase/notifee/blob/ae2953b7d0a0881f7bb925f0f5d0cf1d3ac9daf4/ios/NotifeeCore/NotifeeCoreUtil.m#L151
There is not a lot of logic between the line where files are resolved and content is packaged then sent to the iOS notification center here https://github.com/invertase/notifee/blob/ae2953b7d0a0881f7bb925f0f5d0cf1d3ac9daf4/ios/NotifeeCore/NotifeeCore.m#L181
It's failing with a copy from the bundle. If we use the "bundle" via require
it works. The image itself is small, but there's a small hint in that document you provided
The key part is absolute path meaning the uri
which I normally pass in as file:///... may have an issue
Thar we go
return assets
.filter((it) => it)
.map((it) => ({
id: it.hash!,
thumbnailHidden: false,
typeHint: `public.${it.type}`,
url: it.localUri!.substring('file://'.length),
}));
The documentation should note or at least specify that a url
is a PATH and file://
shouldn't prefix it.
In case anyone is wondering... "expo-notifications" does not work even with the removal of the file://
prefix
But this will break on the second usage of the notification with the same URL because the file moves as alluded to by iOS documentation, knew that before hand so just have to tweak the thing a bit
So I have a work around right now where I clone it on behalf of notifiee
But it would be nice if notifee itself handles those logistics of copying the files and stripping off file://
on it's end because for Expo devs they use URIs exclusively and not file paths.
@trajano that's fantastic you got something working! That's always the first step :-) - I think you're easily the subject matter expert here at the moment, I'd be happy to merge any reasonable PR that improved this area, and the release pipeline has been exercised recently + commit queue is clean so getting it out would be quick
https://github.com/invertase/notifee/issues/931 talks about a remote image.
For now I just want to download an image store it in the "cache" folder so the attachment looks like this
I've tried different variants removing values for ID type etc. With no luck
But the thumbnail image is not appearing
requires
approach does work though.Looking at the examples folder you're using a remote image.
Code https://github.com/trajano/expo-experiments/blob/test-expand-idea/packages/my-app/src/stories/Notification.stories.tsx