sAleksovski / react-native-android-widget

Build Android Widgets with React Native

Home Page:https://sAleksovski.github.io/react-native-android-widget/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

widget is added and automatically deleted so its look Empty

Abiramisaro opened this issue · comments

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;

}
}

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?

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

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

Screen.Recording.2024-02-28.at.5.56.11.PM.mov

Screenshot 2024-02-28 at 6 01 22 PM

@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

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.

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.