Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Incorrect Typing for launchUrl in OSNotification #1714

Closed
2 of 3 tasks
dhafagk opened this issue Jun 10, 2024 · 1 comment
Closed
2 of 3 tasks

[Bug]: Incorrect Typing for launchUrl in OSNotification #1714

dhafagk opened this issue Jun 10, 2024 · 1 comment

Comments

@dhafagk
Copy link

dhafagk commented Jun 10, 2024

What happened?

There appears to be an inconsistency in the typing of the OSNotification in the OneSignal React Native SDK. The event JSON received from the notification contains a property launchUrl, but the OSNotification type defines this property as launchURL (with an uppercase "URL").

Steps to reproduce?

1. implement a notification click handler as below
`const onNotificationClicked = (event: NotificationClickEvent) => {
    const { notification } = event;
    if (notification.launchURL) {
      Linking.canOpenURL(notification.launchURL).then((supported) => {
        if (supported) {
          Linking.openURL(notification.launchURL || '');
        }
      });
    }
  };

  OneSignal.Notifications.addEventListener('click', onNotificationClicked);`
2. Trigger a notification and click on it to handle the event.
3. Observe that the notification object contains launchUrl instead of launchURL.

What did you expect to happen?

The type definition for NotificationClickEvent should match the actual property in the JSON payload received from the event.

React Native OneSignal SDK version

5.2.0

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

{
  "androidNotificationId": 1220805734,
  "body": "test dhafa 4",
  "fromProjectNumber": "555421985318",
  "groupKey": null,
  "groupMessage": null,
  "groupedNotifications": null,
  "launchUrl": "sparkle-mobile://OrderDetail/7a0e1a0d-fac2-4e1c-ad00-3146f1f02c4d",
  "lockScreenVisibility": 1,
  "notificationId": "55c57076-d101-497b-874f-a6d702ae6bd3",
  "priority": 5,
  "rawPayload": "{\"google.delivered_priority\":\"normal\",\"google.sent_time\":1718001785104,\"google.ttl\":259200,\"google.original_priority\":\"normal\",\"custom\":\"{\\\"i\\\":\\\"55c57076-d101-497b-874f-a6d702ae6bd3\\\",\\\"u\\\":\\\"sparkle-mobile:\\/\\/OrderDetail\\/7a0e1a0d-fac2-4e1c-ad00-3146f1f02c4d\\\",\\\"a\\\":{}}\",\"pri\":\"5\",\"vis\":\"1\",\"from\":\"555421985318\",\"alert\":\"test dhafa 4\",\"title\":\"test dhafa 4\",\"google.message_id\":\"0:1718001785114341%66d9a877f9fd7ecd\",\"google.c.sender.id\":\"555421985318\",\"androidNotificationId\":1220805734}",
  "title": "test dhafa 4"
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nan-li
Copy link
Contributor

nan-li commented Jun 10, 2024

Hi @dhafagk thanks for reporting, there is a PR that fixes this which will be available in the next release.

@nan-li nan-li closed this as completed Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants