Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

NextFaze/react-native-manup

A React Native library for handling mandatory app updates and maintenance mode. This library provides a simple way to check if your app version is supported, requires an update, or if the app is in maintenance mode.

Features

  • 🔄Version Validation: Automatically validates app version against minimum and latest requirements
  • 🚧Maintenance Mode: Support for putting apps in maintenance mode
  • 🔥Firebase Remote Config: Integration with Firebase Remote Config for dynamic configuration
  • 🌐HTTP Configuration: Support for HTTP-based configuration endpoints
  • 📱Platform Specific: Different configuration for iOS and Android
  • Real-time Updates: Automatic status updates with callback support

Installation

npm install react-native-manup

Peer Dependencies

This library requires the following peer dependencies:

npm install react-native-device-info

Optional Firebase Dependencies

If you plan to use Firebase Remote Config as your configuration source, you'll also need to install:

npm install @react-native-firebase/app @react-native-firebase/remote-config

Usage

Remote Config Provider

TheRemoteConfigProvider is a unified solution that works with any config source. It provides automatic caching, refetching, and change detection through react-query.

HTTP Configuration Example

Can also see the full example code atexample/App.tsx

importReactfrom'react';import{Alert}from'react-native';import{RemoteConfigProvider,useRemoteConfigManUp}from'react-native-manup';functionApp(){return(<RemoteConfigProviderfetchConfig={async()=>{constresponse=awaitfetch('https://your-api.com/config.json',{cache:'no-store'});if(!response.ok){thrownewError(`HTTP error! status:${response.status}`);}returnresponse.json();}}refetchInterval={3600000}// 1 hour (optional)queryKey="httpConfig"// optional><HomeScreen/></RemoteConfigProvider>);}functionHomeScreen(){const{ status, message}=useRemoteConfigManUp({const onUpdateAvailable=()=>{// - Display update available modal// - Modal can be dismissed};constonUpdateRequired=()=>{// - Display update required modal// - Modal shouldn't be dismissible as user is required to update the app};constonMaintenanceMode=()=>{// - Display maintenance mode modal// - Modal shouldn't be dismissible as the app is in maintenance mode};});return(// Your app content);}

Firebase Remote Config Example

Prerequisite: You must install and set up Firebase in your React Native app before using this provider. Follow theReact Native Firebase setup guide to configure@react-native-firebase/app and@react-native-firebase/remote-config.

importReactfrom'react';import{Alert}from'react-native';import{RemoteConfigProvider,useRemoteConfigManUp}from'react-native-manup';importremoteConfigfrom'@react-native-firebase/remote-config';functionApp(){return(<RemoteConfigProviderfetchConfig={async()=>{awaitremoteConfig().fetchAndActivate();returnJSON.parse(remoteConfig().getValue('appConfig').asString());}}queryKey="firebaseConfig"><HomeScreen/></RemoteConfigProvider>);}functionHomeScreen(){const{ status, message}=useRemoteConfigManUp({const onUpdateAvailable=()=>{// - Display update available modal// - Modal can be dismissed};constonUpdateRequired=()=>{// - Display update required modal// - Modal shouldn't be dismissible as user is required to update the app};constonMaintenanceMode=()=>{// - Display maintenance mode modal// - Modal shouldn't be dismissible as the app is in maintenance mode};});return(// Your app content);}

Configuration

The library expects a configuration object with platform-specific data. Here's the structure:

interfaceConfig{[key:string]:PlatFormData;}interfacePlatFormData{latest:string;// Latest available versionminimum:string;// Minimum supported versionurl:string;// Download URL for the appenabled:boolean;// Whether the app is enabled}

Example Configuration

{"ios": {"latest":"1.2.0","minimum":"1.0.0","url":"https://apps.apple.com/app/yourapp","enabled":true,// Custom platform-specific property - can be any additional data you need"publicApiUrl":"https://api.ios-example.com/v1"  },"android": {"latest":"1.2.0","minimum":"1.0.0","url":"https://play.google.com/store/apps/details?id=com.yourapp","enabled":true,// Custom platform-specific property - can be any additional data you need"publicApiUrl":"https://api.android-example.com/v1"  },// Custom global property - shared across all platforms"publicApiUrl":"https://api.example.com/v1"}

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

License

MIT


Made withcreate-react-native-library

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp