I am getting an error while using manage-wallpaper library in react native

441 views Asked by At

Guys I am trying to use 'react-native-manage-wallpaper' library in my react native application to change the wallpaper...

But I am getting this error:

TypeError: null is not an object (evaluating'_reactNative.NativeModules.ManageWallpaper.setWallpaper')

This is the function which is being used to change the wallpaper

 const callback = res => {
    console.log('Response: ', res);
  };

const changeWallpaper = () => {
    ManageWallpaper.setWallpaper(
      {
        uri: 'https://i.pinimg.com/originals/76/5e/1d/765e1dc8cb1cc115fb3b0b39a895fdeb.jpg',
      },
      callback,
      TYPE.HOME,
    );
  };

What exactly is causing the error?

1

There are 1 answers

0
Md Alishan Ali On

I was also facing the same issue. But after the loss of hassle I know one package called @ajaybhatia/react-native-wallpaper-manager

https://www.npmjs.com/package/@ajaybhatia/react-native-wallpaper-manager npm install --save @ajaybhatia/react-native-wallpaper-manager

import WallPaperManager from '@ajaybhatia/react-native-wallpaper-manager';
WallPaperManager.setWallpaper({uri: 'http://example.com/test.png', screen: 'lock/home/both'}, res => console.log(res));
I think this package can help you guys. Feel free to check the github of this package https://github.com/ajaybhatia/react-native-wallpaper-manager

If you are using expo then expo go has not native module. So first you have to build your app using this command

eas build --profile development --platform android 
Then from expo.dev you have to install the app and run on your app. It will perfectly. Thank you let me know If you face any issue.