react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Possibility on Android to pass notification channel ID

Open alexandrubichis opened this issue 3 years ago • 7 comments

Possibility on Android to pass notification channel ID. In case the channel ID is not found the SDK should create a new one.

Your Environment

  • Plugin version: 4.8.2
  • Platform: Android
  • OS version: 12
  • Device manufacturer / model: Samsung S20FE 5G
  • React Native version (react-native -v): 0.68
  • Plugin config
await BackgroundGeolocation.ready({
      // Geolocation Config
      enableHeadless: true, 
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 10,
      stopTimeout: 10, 
      // Application config
      debug: false, 
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,
      startOnBoot: true, 
      isMoving: true, 
      url: `${baseUrl}/location`,
      batchSync: false,
      autoSync: true, 
      headers: { 
        "Content-Type": "application/json",
        "Authorization": `${authorization}`
      },
      disableLocationAuthorizationAlert: false,
      locationAuthorizationRequest: "Any",
      backgroundPermissionRationale: {
        message: I18n.t("request_permissions_bk_location"),
        negativeAction: I18n.t("no_label"),
        positiveAction: I18n.t("yes_label")
      },
      locationTemplate: '{"latitude":<%= latitude %>,"longitude":<%= longitude %>, "activity": "<%= activity.type %>"}',
      httpRootProperty: ".",
      notification: {
        smallIcon: "mipmap/ic_notification",
        color: "#02d1bb",
        channelName: "Location tracking"
      }
    });

Expected Behavior

To add channelID parameter to the notification and use it as the notification channel. If the notification manager does not find the channel ID then create a new one as is implemented currently.

await BackgroundGeolocation.ready({
      // Geolocation Config
      enableHeadless: true, 
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 10,
      stopTimeout: 10, 
      // Application config
      debug: false, 
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,
      startOnBoot: true, 
      isMoving: true, 
      url: `${baseUrl}/location`,
      batchSync: false,
      autoSync: true, 
      headers: { 
        "Content-Type": "application/json",
        "Authorization": `${authorization}`
      },
      disableLocationAuthorizationAlert: false,
      locationAuthorizationRequest: "Any",
      backgroundPermissionRationale: {
        message: I18n.t("request_permissions_bk_location"),
        negativeAction: I18n.t("no_label"),
        positiveAction: I18n.t("yes_label")
      },
      locationTemplate: '{"latitude":<%= latitude %>,"longitude":<%= longitude %>, "activity": "<%= activity.type %>"}',
      httpRootProperty: ".",
      notification: {
        smallIcon: "mipmap/ic_notification",
        color: "#02d1bb",
        channelD: CHANNEL_ID
      }
    });

alexandrubichis avatar Sep 22 '22 13:09 alexandrubichis

So are you creating your own NotificationChannel, and hoping to have the plugin use your own channel?

christocracy avatar Sep 22 '22 14:09 christocracy

So are you creating your own NotificationChannel, and hoping to have the plugin use your own channel?

Yes indeed.

alexandrubichis avatar Sep 22 '22 14:09 alexandrubichis

I will look into adding Notification.channelId.

christocracy avatar Sep 22 '22 15:09 christocracy

I will look into adding Notification.channelId.

We would appreciate if you can add it. We are using it commercially (with license) and having two foreground services in the notification bar on Android doesn't look professional. And we can't reuse your channel as these two use-cases don't overlap 100% in terms of when they are used.

Thanks

BlackJohnny avatar Sep 23 '22 09:09 BlackJohnny

Authorization.channelId has been pushed to branch release-4.8.3. Please test by installing the plugin from the private repo

yarn add https://github.com/transistorsoft/react-native-background-geolocation-android#release-4.8.3

christocracy avatar Sep 26 '22 17:09 christocracy

Tagged in private repo as 4.9.0

christocracy avatar Sep 29 '22 14:09 christocracy

Authorization.channelId has been pushed to branch release-4.8.3. Please test by installing the plugin from the private repo

yarn add https://github.com/transistorsoft/react-native-background-geolocation-android#release-4.8.3

update status: Sorry for the delay, we are stuck in some 'notification group' related issues/arhitecture. We'll provide feedback soon. Thanks

BlackJohnny avatar Oct 03 '22 09:10 BlackJohnny

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jun 05 '24 01:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jun 19 '24 01:06 github-actions[bot]