rn-manage-wallpaper
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

rn-manage-wallpaper

this package allows you to access wallpaper tools from native apis

Installation

yarn add rn-manage-wallpaper

After install run this to link the packages.

yarn android

permissions

this package needs the following permissions:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Usage

WallpaperManager has one function called setWallpaper that receives 2 arguments, file uri and a flag that indicates whenever it will be set as lock screen or system screen, FLAG_LOCK and FLAG_SYSTEM for reference, you can get their values using the getConstants function.

Example

in this example i use RNFetchBlob to donwload a web image and use the cache file path to define the wallpaper

import WallpaperManager from 'rn-manage-wallpaper';

// ...

const FLAG_CONSTANTS = WallpaperManager.getConstants();
RNFetchBlob.config({
      // add this option that makes response data to be stored as a file,
      fileCache: true,
    })
      .fetch('GET', image.url, {
        //some headers ..
      })
      .then(res => {
        try {
          WallpaperManager.setWallpaper(`${res.path()}`, FLAG_CONSTANTS.FLAG_SYSTEM);
        } catch (error) {
          console.log(error);
        }
      });

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i rn-manage-wallpaper

Weekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

90.9 kB

Total Files

21

Last publish

Collaborators

  • deono