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]: Can't initialize OneSignal on iPhone #1568

Closed
2 of 3 tasks
Bjarkinn opened this issue Sep 26, 2023 · 6 comments
Closed
2 of 3 tasks

[Bug]: Can't initialize OneSignal on iPhone #1568

Bjarkinn opened this issue Sep 26, 2023 · 6 comments
Labels

Comments

@Bjarkinn
Copy link

Bjarkinn commented Sep 26, 2023

What happened?

If the language on an iPhone 14 is set to Icelandic and the following code is run we get the error shown in the first image and no push subscription is created on the OneSignal dashboard

OneSignal.Debug.setAlertLevel(LogLevel.Warn)
OneSignal.initialize(ONESIGNAL_APP_ID)

If the preferred language is then changed from Icelandic to English and the app reinstalled, OneSignal intialized correctly and a push subscription is created on the OneSignal dashboard

Steps to reproduce?

Installed packages
"react": "18.2.0",
"react-native": "0.72.4",
"expo": "49.0.9",
"react-native-onesignal": "5.0.0",

1. Set Icelandic as the first preferred language on an iPhone (might be an issue with other languages as well)
2. Install the app on the iPhone, initialize OneSignal and look at logs (LogLevel.Warn)
   See that OneSignal returns an error
3. Change the preferred language to English and reinstall the app
   OneSignal initialized without an error and a subscription was created on the OneSignal dashboard

What did you expect to happen?

I expect OneSignal to initialize no matter what language the phone is set to. Should fallback to some default language if given language can't be supported

React Native OneSignal SDK version

5.0.0

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Bjarkinn
Copy link
Author

A little followup question.

We have now been using OneSignal in production for few weeks and are receiving more and more complaints about users not getting any push notifications. Those users usually don't have any OneSignal subscription because of this bug so they understandable can't receive any notifications. Many of those users do have Icelandic as their preferred language so its clear that this is not a one-off issue.

@nan-li Have you or anyone at your teem had the chance to look into this? My guess is that this issue is not isolated to Icelandic and could be affecting many users

@jfishman1
Copy link

Please update to react-native-onesignal 5.0.2 https://github.com/OneSignal/react-native-onesignal/releases

Then follow this guide to share a log from the device, you can share as a .txt file here or with [email protected]: https://documentation.onesignal.com/docs/capturing-a-debug-log

You should see the language default to English for any languages we don't support.

For notifications not shown, see this guide: https://documentation.onesignal.com/docs/notifications-show-successful-but-are-not-being-shown

If you need further assistance, contact [email protected] and our team can help directly.

@magtastic
Copy link

magtastic commented Oct 26, 2023

@jfishman1

This issue probably belongs in the iOS SDK repo, but here are the logs;

...SOME LOGS... 
VERBOSE: getNotificationTypes:mSubscriptionStatus: -1
VERBOSE: HTTP Request (OneSignalUser.OSRequestCreateUser) with URL: https://api.onesignal.com/apps/3e6ee5a8-e283-4581-9f8d-f0830c633825/users, with parameters: {
  "identity" : {

  },
  "subscriptions" : [
    {
      "device_os" : "17.0.3",
      "enabled" : false,
      "net_type" : 0,
      "device_model" : "iPhone14,4",
      "test_type" : 1,
      "app_version" : "1.0.0",
      "type" : "iOSPush",
      "token" : "62c6cac0e5f7d57d2a4705adcc97ea5c3085973d73d449f5ac596ddb1698fbbd",
      "notification_types" : -18,
      "sdk" : "050002"
    }
  ],
  "properties" : {
    "timezone_id" : "Atlantic\/Reykjavik",
    "language" : "is-IS"
  }
}
VERBOSE: init redisplayedInAppMessages with: {
}
VERBOSE: startNewSession
VERBOSE: startNewSessionInternal
DEBUG: Outcomes cleared for current session
DEBUG: OneSignal SessionManager restartSessionIfNeeded with entryAction:: 2 channelTrackers: (
)
DEBUG: OneSignal SessionManager sendSessionEndingWithInfluences with influences: (
)
VERBOSE: getNotificationTypes:mSubscriptionStatus: -1
VERBOSE: OneSignalUserManagerImpl starting new session
VERBOSE: network response (OSRequestGetIosParams): {
    httpStatusCode = 200;
    outcomes =     {
        direct =         {
            enabled = 1;
        };
        indirect =         {
            enabled = 1;
            "notification_attribution" =             {
                limit = 10;
                "minutes_since_displayed" = 60;
            };
        };
        unattributed =         {
            enabled = 1;
        };
    };
    "receive_receipts_enable" = 1;
    "uses_provisional_auth" = 0;
}
VERBOSE: network response (OneSignalUser.OSRequestCreateUser): {
    errors =     (
                {
            title = "The provided language value is not a supported ISO 639-1 value";
        }
    );
    httpStatusCode = 400;
}
ERROR: OSUserExecutor create user request failed with error: Optional(Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
    errors =     (
                {
            title = "The provided language value is not a supported ISO 639-1 value";
        }
    );
    httpStatusCode = 400;
}})
DEBUG: OSOperationRepo not flushing queue due to being paused
DEBUG: OSOperationRepo not flushing queue due to being paused
VERBOSE: OneSignal.User login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager internal _login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManagerImpl prepareForNewUser called
DEBUG: OSOperationRepo not flushing queue due to being paused
VERBOSE: HTTP Request (OneSignalUser.OSRequestCreateUser) with URL: https://api.onesignal.com/apps/3e6ee5a8-e283-4581-9f8d-f0830c633825/users, with parameters: {
  "identity" : {

  },
  "subscriptions" : [
    {
      "test_type" : 1,
      "device_os" : "17.0.3",
      "type" : "iOSPush",
      "enabled" : false,
      "device_model" : "iPhone14,4",
      "token" : "62c6cac0e5f7d57d2a4705adcc97ea5c3085973d73d449f5ac596ddb1698fbbd",
      "net_type" : 0,
      "notification_types" : -18,
      "app_version" : "1.0.0",
      "sdk" : "050002"
    }
  ],
  "properties" : {
    "timezone_id" : "Atlantic\/Reykjavik",
    "language" : "is-IS"
  }
}
VERBOSE: network response (OneSignalUser.OSRequestCreateUser): {
    errors =     (
                {
            title = "The provided language value is not a supported ISO 639-1 value";
        }
    );
    httpStatusCode = 400;
}
ERROR: OSUserExecutor create user request failed with error: Optional(Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
    errors =     (
                {
            title = "The provided language value is not a supported ISO 639-1 value";
        }
    );
    httpStatusCode = 400;
}})
DEBUG: OSOperationRepo not flushing queue due to being paused
DEBUG: OSOperationRepo not flushing queue due to being paused
VERBOSE: OneSignal.User login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager internal _login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager.createNewUser: not creating new user due to logging into the same user.)
DEBUG: OSOperationRepo not flushing queue due to being paused
DEBUG: OSOperationRepo not flushing queue due to being paused

Note:

VERBOSE: OneSignal.User login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager internal _login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManagerImpl prepareForNewUser called
DEBUG: OSOperationRepo not flushing queue due to being paused
VERBOSE: HTTP Request (OneSignalUser.OSRequestCreateUser) with URL: https://api.onesignal.com/apps/3e6ee5a8-e283-4581-9f8d-f0830c633825/users, with parameters: {
  "identity" : {

  },
  "subscriptions" : [
    {
      "test_type" : 1,
      "device_os" : "17.0.3",
      "type" : "iOSPush",
      "enabled" : false,
      "device_model" : "iPhone14,4",
      "token" : "62c6cac0e5f7d57d2a4705adcc97ea5c3085973d73d449f5ac596ddb1698fbbd",
      "net_type" : 0,
      "notification_types" : -18,
      "app_version" : "1.0.0",
      "sdk" : "050002"
    }
  ],
  "properties" : {
    "timezone_id" : "Atlantic\/Reykjavik",
    "language" : "is-IS"
  }
}
VERBOSE: network response (OneSignalUser.OSRequestCreateUser): {
    errors =     (
                {
            title = "The provided language value is not a supported ISO 639-1 value";
        }
    );
    httpStatusCode = 400;
}
ERROR: OSUserExecutor create user request failed with error: Optional(Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
    errors =     (
                {
            title = "The provided language value is not a supported ISO 639-1 value";
        }
    );
    httpStatusCode = 400;
}})

As you can see, the server is returning a 400 error, saying that is is not a supported ISO 639-1 value (it is https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).

The error is logged here: https://github.com/OneSignal/OneSignal-iOS-SDK/blob/major_release_5.0.0/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserRequests.swift#L331

I cannot see how it defaults to english.

Calling the login method again results in;

VERBOSE: OneSignal.User login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager internal _login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager.createNewUser: not creating new user due to logging into the same user.)

This VERBOSE: OneSignalUserManager.createNewUser: not creating new user due to logging into the same user.) message persists between app sessions. (restarting the app does not call the server again).

(logs from after the app was restarted

initOneSignal
VERBOSE: setAppId called with appId: 3e6ee5a8-e283-4581-9f8d-f0830c633825!
VERBOSE: setLaunchOptions() called with launchOptions: (null)!
VERBOSE: launchOptions is set and appId of 3e6ee5a8-e283-4581-9f8d-f0830c633825 is set, initializing OneSignal...
DEBUG: OSOperationRepo not flushing queue due to being paused
VERBOSE: OneSignal.User login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager internal _login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager.createNewUser: not creating new user due to logging into the same user.)
DEBUG: OSOperationRepo not flushing queue due to being paused
VERBOSE: OneSignal.User login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager internal _login called with externalId: fake_external_user_id_7
VERBOSE: OneSignalUserManager.createNewUser: not creating new user due to logging into the same user.)
DEBUG: OSOperationRepo not flushing queue due to being paused

)

Running the following code in this state results in;

		const subId = OneSignal.User.pushSubscription.getPushSubscriptionId();
		const token = OneSignal.User.pushSubscription.getPushSubscriptionToken();
		console.log(subId, token); // undefined, SOME_VALID_TOKEN

Steps to reproduce

  1. Create a new react native project with npx create-expo-app one_signal_example
  2. run npx expo install expo-dev-client
  3. Setup OneSignal according to documentation here: https://documentation.onesignal.com/docs/react-native-expo-sdk-setup
  4. Set default language on iOS device as Icelandic and run the app on the device

IMO I see two issues here;

  1. Your internal server does not think the Icelandic language has a valid ISO 639-1 code.
  2. Your iOS SDK does not handle this error gracefully e.g. falling back to english

This is with version 5.0.2.

package.json;

{
  "name": "one_signal_example",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web --dev-client",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^13.0.0",
    "@react-navigation/native": "^6.0.2",
    "expo": "~49.0.15",
    "expo-build-properties": "~0.8.3",
    "expo-dev-client": "~2.4.11",
    "expo-font": "~11.4.0",
    "expo-linking": "~5.0.2",
    "expo-router": "^2.0.0",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "expo-system-ui": "~2.4.0",
    "expo-web-browser": "~12.3.2",
    "onesignal-expo-plugin": "^2.0.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.72.6",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-onesignal": "^5.0.2",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-web": "~0.19.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react": "~18.2.14",
    "jest": "^29.2.1",
    "jest-expo": "~49.0.0",
    "react-test-renderer": "18.2.0",
    "typescript": "^5.1.3"
  },
  "overrides": {
    "react-refresh": "~0.14.0"
  },
  "resolutions": {
    "react-refresh": "~0.14.0"
  },
  "private": true
}

Created an issue on the iOS SDK; OneSignal/OneSignal-iOS-SDK#1329

@nan-li
Copy link
Contributor

nan-li commented Nov 2, 2023

Hi @Bjarkinn and @magtastic, we have updated our server to accept more language codes including Icelandic.

You should be able to initialize with that language now. In addition, any app installations on iOS that were previously failing due to unsupported language should now recover and succeed.

And you are both right, it is not isolated to a single language and we are working on a better recovery option when this failure occurs.

@samovesel
Copy link

There is the same problem with language sl in Web SDK. Can you fix it please?
Object { title: "The provided language value is not a supported ISO 639-1 value" }

@samovesel
Copy link

Hi @Bjarkinn and @magtastic, we have updated our server to accept more language codes including Icelandic.

You should be able to initialize with that language now. In addition, any app installations on iOS that were previously failing due to unsupported language should now recover and succeed.

And you are both right, it is not isolated to a single language and we are working on a better recovery option when this failure occurs.

Can you please add also Slovenian (sl) and also other languages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants