React-native-notifee: Show image that requires authentication as a largeIcon

Created on 8 Dec 2020  路  4Comments  路  Source: notifee/react-native-notifee

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!

documentation

All 4 comments

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:

  1. Add to manifest: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> and
  1. 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hmazer picture hmazer  路  4Comments

joshuacano picture joshuacano  路  6Comments

pyeonjaesik picture pyeonjaesik  路  6Comments

ashokkumar88 picture ashokkumar88  路  6Comments

robertqin86 picture robertqin86  路  3Comments