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

fix(api): fix onesignal ios_badgeCount and ios_badgeType typos #7273

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

L-U-C-K-Y
Copy link
Contributor

@L-U-C-K-Y L-U-C-K-Y commented Dec 11, 2024

What changed? Why was the change needed?

fixes #7199

Hi all

We were debugging some things and noticed the following:

In both, the old and new OneSignal API, the keys for ios_badge_type and ios_badge_count is defined as:

  • ios_badgeType
  • ios_badgeCount

New API: https://documentation.onesignal.com/reference/push-notification
Old API: https://documentation.onesignal.com/v9.0/reference/push-channel-properties

In the Novu code, the following are used:

  • ios_badge_type
  • ios_badge_count

Questions:

1. What is protected keyCaseObject: Record<string, string> = {?

Does the this.transform function, change any of the keys? Is it related to protected keyCaseObject: Record<string, string> = {

Because in protected keyCaseObject we use ios_badgeType and ios_badgeCount:

packages/providers/src/lib/push/one-signal/one-signal.provider.ts

protected keyCaseObject: Record<string, string> = {
    is_ios: 'isIos',
    is_android: 'isAndroid',
    is_huawei: 'isHuawei',
    is_any_web: 'isAnyWeb',
    is_chrome_web: 'isChromeWeb',
    is_firefox: 'isFirefox',
    is_safari: 'isSafari',
    is_wp_wns: 'isWP_WNS',
    is_adm: 'isAdm',
    is_chrome: 'isChrome',
    ios_badge_type: 'ios_badgeType', // correct ios_badgeType
    ios_badge_count: 'ios_badgeCount', // correct ios_badgeCount
  };
const notification = this.transform(bridgeProviderData, {
      include_player_ids: options.target,
      app_id: this.config.appId,
      headings: { en: options.title },
      contents: { en: options.content },
      subtitle: { en: overrides.subtitle },
      data: options.payload,
      ios_badge_type: 'Increase', // wrong ios_badge_type
      ios_badge_count: 1, // ios_badge_count
      ios_sound: sound,
      android_sound: sound,
      mutable_content: overrides.mutableContent,
      android_channel_id: overrides.channelId,
      small_icon: overrides.icon,
      large_icon: overrides.icon,
      chrome_icon: overrides.icon,
      firefox_icon: overrides.icon,
      ios_category: overrides.categoryId,
    }).body;

2 Duplicate Keys

Why are both keys in the unit test ios_badgeCount and ios_badge_count?

packages/providers/src/lib/push/one-signal/one-signal.provider.spec.ts

expect(data).toEqual({
      include_player_ids: ['tester'],
      app_id: 'test-app-id',
      headings: { en: 'Test' },
      contents: { en: 'Test push' },
      subtitle: {},
      data: { sound: 'test_sound' },
      ios_badge_type: 'Increase',
      ios_badgeCount: 2, // correct key name
      ios_badge_count: 1, // wrong key name
      include_external_user_ids: ['test'],
    });
Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Dec 11, 2024

👷 Deploy request for dev-web-novu pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f80283c

Copy link

netlify bot commented Dec 11, 2024

👷 Deploy request for dashboard-v2-novu-staging pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f80283c

@L-U-C-K-Y L-U-C-K-Y changed the title fix(api): fix onesignal ios_badgeCount and ios_badgeType fix(api): fix onesignal ios_badgeCount and ios_badgeType wrong keys Dec 17, 2024
@L-U-C-K-Y L-U-C-K-Y changed the title fix(api): fix onesignal ios_badgeCount and ios_badgeType wrong keys fix(api): fix onesignal ios_badgeCount and ios_badgeType typos Dec 17, 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

Successfully merging this pull request may close these issues.

🐛 Bug Report: OneSignal ios_badge_type and ios_badge_count issue
2 participants