Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
retyui authored Feb 8, 2024
1 parent 87452d6 commit cfecdcb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,29 @@ public class MainActivity extends ReactActivity {
}
```

Kotlin `MainActivity.kt` example:

```diff
+import com.retyui.widgetpicker.WidgetPickerModuleImpl.Companion.registerWidgetClass

class MainActivity : ReactActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ registerWidgetClass("MyAppWidget", MyAppWidget::class.java)
+ }
}
```

## Usage

```tsx
import {WidgetPicker} from 'react-native-widget-picker';

WidgetPicker.isRequestPinAppWidgetSupported() // true or false

WidgetPicker.requestPinAppWidget("MyAppWidget").then((value) => { // "MyAppWidget" - name from MainActivity.java
// "MyAppWidget" - name from MainActivity.java or .kt
WidgetPicker.requestPinAppWidget("MyAppWidget").then((value) => {

if (value.message === "success") {
// success
}
Expand Down

0 comments on commit cfecdcb

Please sign in to comment.