sAleksovski / react-native-android-widget

Build Android Widgets with React Native
https://sAleksovski.github.io/react-native-android-widget/
MIT License
546 stars 22 forks source link

widget is added and automatically deleted so its look Empty #66

Closed Abiramisaro closed 4 months ago

Abiramisaro commented 4 months ago

Hi, by console in the switch statements i get the logs "widget added" and "widget deleted" the widgetTaskHandler function : export async function widgetTaskHandler(props: WidgetTaskHandlerProps) { const widgetInfo = props.widgetInfo; console.log(widgetInfo,"widgetInfo....") const Widget = nameToWidget[widgetInfo.widgetName as keyof typeof nameToWidget];

switch (props.widgetAction) { case 'WIDGET_ADDED': console.log("WIDGET ADDED>>") props.renderWidget(); break;

case 'WIDGET_UPDATE':
  console.log("WIDGET updated>>")
  // Not needed for now
  break;

case 'WIDGET_RESIZED':
  console.log("WIDGET resized...>>")
  // Not needed for now
  break;

case 'WIDGET_DELETED':
  console.log("widget deleted..")
  // Not needed for now
  break;

case 'WIDGET_CLICK':
  console.log("Widget clicked..")
  // Not needed for now
  break;

default:
  break;

} }

sAleksovski commented 4 months ago

This is not related to the library. It just responds to Android events.

Can you share a screen recording? Can you try a widget from a different app?

Abiramisaro commented 4 months ago

@sAleksovski now its this issue cleared by enter a correct package name.

Abiramisaro commented 4 months ago

but now the widget is opened and suddently when i come out from the widget configure screen the widget is deleted . I console that for debugging. here i attach a video and screenshots . pls help to sort it out

https://github.com/sAleksovski/react-native-android-widget/assets/102860366/ddb870f4-4126-46a1-ad80-673ccc68b5d8

Screenshot 2024-02-28 at 6 01 22 PM

Abiramisaro commented 4 months ago

@sAleksovski in the Make Widget configurable page declared a note we have to the fallback configuration to avoid widget deletion after we add widget to the homescreen... pls explain this one Screenshot 2024-02-28 at 6 49 29 PM

sAleksovski commented 4 months ago

The widget configuration screen is optional. Since your screen is empty, you can make the widget not configurable.

If you want your widget to be configurable, you will need to add some button in the configuration screen, which will call setResult('ok').

See https://saleksovski.github.io/react-native-android-widget/docs/api/register-widget-configuration-screen

The default behavior when going back from the widget configuration screen is to remove the widget. You must call setResult('ok') for the widget to stay on the screen. Check the configuration screen in the example app.

sAleksovski commented 4 months ago

Closing since it appears that you did not call setResult('ok') before exiting the configuration screen.

If you still have the problem, reopen the issue with example code reproducing the issue.