Cannot implement LocationNotificationTrigger

Please provide the following:

  1. SDK Version:39
  2. Platforms(Android/iOS/web/all): iOS

I’m trying to implement a location based notification. The Expo-Notification documentation mention LocationNotificationTrigger, however, it is not clear how to schedule such notification.

from this post: LocationNotificationTrigger for local notification it seems that expo don’t support LocationNotificationTrigger.

What am I missing?
in what way LocationNotificationTrigger is supported? (and if it doesn’t, what the point of having it in the documentation?).

another suggestion made by @charliecruzan is to use Expo-Location Geofencing Methods. Unfortunately, so far I haven’t been able to get reliable and consistent results with it. Googling this issue just led me to more and more people that struggle with it.

@charliecruzan - can you provide feedback?

Expo does support LocationNotificationTriggers on iOS, I’ll edit my answer on that older forum post now :slight_smile:

If it’s not working for you, the best way to get help is to share the code you’re trying to use that isn’t working

Thank you @charliecruzan for your quick response!

here is the code I’m using:

Notifications.scheduleNotificationAsync({
        content: {
          title: "Test notification 2",
          body: "body test",
        },
        trigger: {
          type: "location",
          repeats: true,
          region: {
            type: "circular",
            identifier: "testnotification",
            notifyOnEntry: true,
            notifyOnExit: true,
            radius: 50,
            center: {
              latitude: 40.1234,
              longitude: -80.1234,
            },
          },
        },
      }).then((string) => console.log(string));
      Notifications.getAllScheduledNotificationsAsync().then((value) =>
        console.log(value)
      );

and this is the log I receive:

89892472-18f5-4e51-b441-d22329a390d3
Array [
  Object {
    "content": Object {
      "attachments": Array [],
      "badge": null,
      "body": "body test",
      "categoryIdentifier": "",
      "data": Object {
        "experienceId": "#############",
      },
      "launchImageName": "",
      "sound": null,
      "subtitle": null,
      "summaryArgument": "",
      "summaryArgumentCount": 0,
      "targetContentIdentifier": null,
      "threadIdentifier": "",
      "title": "Test notification 2",
    },
    "identifier": "89892472-18f5-4e51-b441-d22329a390d3",
    "trigger": Object {
      "class": "UNCalendarNotificationTrigger",
      "dateComponents": Object {
        "calendar": "iso8601",
        "isLeapMonth": false,
        "timeZone": null,
      },
      "repeats": true,
      "type": "calendar",
    },
  },
]

As you can see, the code does schedule a notification, but with UNCalendarNotificationTrigger as class (clearly not UNLocationNotificationTrigger as I thought I should expect).

What am I missing? Is there a different way to schedule a Local Notification?
Thanks ahead!

ah you know what, now reading the relevant code I can see that the Location notification trigger on iOS is only meant for Mac Catalyst. Although this does reveal a bug in expo-notification- it should return an error if you try to schedule a notification type that isn’t supported. I can open an issue for that

Thanks again for the quick response. Too bad it is not supported…
Hopefully it will be supported in the future.
Cheers!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.