react-native-widget-picker
v1.0.3
Published
Request to pin an app widget on the current launcher
Downloads
187
Maintainers
Readme
react-native-widget-picker
Let users pin a widget. On devices running Android 8.0 (API level 26) and higher, launchers that let pin widgets onto their home screen
https://github.com/retyui/react-native-detect-maestro/assets/4661784/e301602d-d82e-4f5f-b259-1bae3677b868
Getting started
- Android only
- support React Native's New & Old Architecture
yarn add react-native-widget-picker
# or
npm install react-native-widget-picker
Edit android/app/src/main/java/com/.../MainActivity.java
and add:
+import com.retyui.widgetpicker.WidgetPickerModuleImpl;
public class MainActivity extends ReactActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ WidgetPickerModuleImpl.registerWidgetClass("MyAppWidget", MyAppWidget.class);
// you can register multiple widgets ^^^
}
Usage
import {WidgetPicker} from 'react-native-widget-picker';
WidgetPicker.isRequestPinAppWidgetSupported() // true or false
WidgetPicker.requestPinAppWidget("MyAppWidget").then((value) => { // "MyAppWidget" - name from MainActivity.java
if (value.message === "success") {
// success
}
});
License
MIT