4

How to enable option "set as wallpaper" ? I'm using expo and I'm not able to find any API to enable that functionality. I only able to download image. I want to trigger set as wallpaper option. I tried to use react-native-wallpaper-manager library but it has not worked for me.

Nirbhay Singh
  • 1,204
  • 1
  • 12
  • 16
Nilesh Kant
  • 351
  • 2
  • 10

2 Answers2

3

I found the proper solution to 'set wallpaper' (in android) using react-native-wallpaper-manager by ejecting the CRNA . But it seems like the npm release is not up to date with the repo. To get it to work you will have to implement the last pull fix manually by removing

@Override
    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

from WallPaperPackage.java and make sure to link the package by react-native link react-native-wallpaper-manager

Note:- Right now there is no api working with expo or CRNA to 'set as wallpaper' in android

Nilesh Kant
  • 351
  • 2
  • 10
  • Got error `underfined is not a function (evaluating _reactNativeWallpaperManager2.default.setWallpaper....` – TomSawyer Aug 10 '18 at 19:30
  • 1
    After npm install you need to remove that particular line in WallPaperPakage.java as I mention above and then react-native link. Make sure that at that time you should open android studio. – Nilesh Kant Aug 13 '18 at 19:01
0

you can use NativeModules from react-native

import NativeModules from 'react-native';

NativeModules.WallPaperManager.setWallpaper(image,callback);
hannad rehman
  • 4,133
  • 3
  • 33
  • 55