I'm looking for a way to show image that requires authentication as a largeIcon.
I'm thinking about two ways.
set largeIcon with HTTP header.
We can set HTTP header to Image of React Native.
<Image
source={
{ uri: 'https://foo/bar.jpg',
headers: {
Authorization: 'Bearer XXX'
}
}
}/>
Can we have a way to set HTTP Header into largeIcon?
download image and set absolute file path to largeIcon
I can fetch the image that requires authentication. I tried to download the image and set it to largeIcon as below.
notification.android.largeIcon = `file://xxxx/xxxx/xxxx.jpg`;
Unfortunately it didn't works.(This way works fine with react native firebase V5)
Can't we use the absolute file path?
Thanks for great works!
Interesting...I think setting headers etc may take us down a networking rabbit hole but loading it from a file is probably a change that could be done here. Worth investigating
@hibinoA can you try changing the path to have three /'after file:, e.g. "file:///xxxx/xxxx/xxxx.jpg". I've done a test myself and it works, but you will need to have the correct permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> and request permission for Android M's new permissions model:
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,....
If it still fails to load the image but displays the notification, you should be able to see in the android logs:
E/NOTIFEE: (ResourceUtils): Failed to load an image: file:///xxxx/xxxx/xxxx.jpg
Let us know if that helps.
@helenaford
can you try changing the path to have three /'after file:, e.g. "file:///xxxx/xxxx/xxxx.jpg".
It works fine! Thanks for your helping and great works:smile:
You're welcome. Will add something to the docs describing how to add an absolute file path.