voximplant / react-native-foreground-service

React native module to start foreground service on android
MIT License
159 stars 91 forks source link

Setting Icon Name #2

Closed bennito254 closed 5 years ago

bennito254 commented 5 years ago

How is the icon name supposed to be set?

Plus, I also second @agat from #issue 1. A simple screen with Start, Stop buttons will be fine to get everybody started. Thank you for the library.

YuliaGrigorieva commented 5 years ago

Hello!

Icon name should be set to NotificationConfig.icon as string representing icon name. Icon for the notification should be located in drawable or mipmap resource directory of the android app folder.

We have creates a simple demo project: https://github.com/voximplant/react-native-foreground-service-demo

Demo project contains notification icon (ic_notification.png) in drawable-..dpi folders, for example: https://github.com/voximplant/react-native-foreground-service-demo/tree/master/android/app/src/main/res/drawable-hdpi Icon name is set the following way:

const notificationConfig = {
    id: 3456,
    title: 'Foreground Service',
    text: 'Foreground service is running',
    icon: 'ic_notification',
    priority: 0
};

See full source code here

Best regards, Yulia Grigorieva

bennito254 commented 5 years ago

Thank you sir!

roysG commented 5 years ago

Where do you add the execute background code?