OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
615 stars 213 forks source link

[Bug]: Login sometime not working on iOS and HTTP Client Error with status code: 500 #919

Open FantaMagier opened 2 months ago

FantaMagier commented 2 months ago

What happened?

On the latest version of the Flutter OneSignal SDK, I think the login function doesn't work on some devices. The patch request https://api.onesignal.com/apps/APPID/users/by/onesignal_id/ONESIGNALID gets a 500 request on some iOS devices. In the OneSignal dashboard you can see that login sometimes does not work. I think this is related.`

Steps to reproduce?

1. Install latest OneSignal Flutter SDK
2. Use this Code: (I am useing the Qonversion User ID which is working on Android and on some iOS Devices) This ID is a normal String 

Init in main:

OneSignal.Debug.setLogLevel(isTestMode ? OSLogLevel.verbose : OSLogLevel.none);

  OneSignal.consentRequired(true);

  OneSignal.initialize(ID);

In the Func to start the prompt

  await OneSignal.consentGiven(true);
              QUser qonID = await Qonversion.getSharedInstance().userInfo();

              // ignore: unnecessary_string_interpolations
              await OneSignal.login("${qonID.qonversionId.toString()}");

              await OneSignal.Notifications.requestPermission(true);

What did you expect to happen?

The External ID is set correctly and the user don't get a 500 Response Code

OneSignal Flutter SDK version

onesignal_flutter: ^5.2.2

Which platform(s) are affected?

Relevant log output

No response

Code of Conduct

jkasten2 commented 1 month ago

@FantaMagier could you share the exact payload from the xcode log that is getting the 500 error? You may have to enable OneSignal verbose logging.

FantaMagier commented 1 month ago

@jkasten2 I got the following logs:

VERBOSE: HTTP Request (OneSignalUser.OSRequestIdentifyUser) with URL: https://api.onesignal.com/apps/APPID/users/by/onesignal_id/ONESIGNALID/identity, with parameters: {
  "identity" : {
    "external_id" : "QON_54eb6b1ca96d419babc4efa1cfe3ed3e"
  }
}
[Sentry] [debug] [SentryNetworkTracker:390] Response status code isn't within the allowed ranges, not capturing HTTP Client errors.
VERBOSE: network response (OSRequestGetInAppMessages) with URL https://api.onesignal.com/apps/APPID/subscriptions/NUM/iams: {
    httpStatusCode = 200;
    "in_app_messages" =     (
    );
}
VERBOSE: getInAppMessagesFromServer success
VERBOSE: updateInAppMessagesFromServer
[Sentry] [debug] [SentryScope:125] Add breadcrumb: <SentryBreadcrumb: 0x3018df240, {
    category = http;
    data =     {
        method = GET;
        reason = "no error";
        "request_body_size" = 0;
        "response_body_size" = 22;
        "status_code" = 200;
        url = "https://api.onesignal.com/apps/APPID/subscriptions/SUBNUM/iams";
    };
    level = info;
    timestamp = "2024-07-19T04:08:19.108Z";
    type = http;
}>
nan-li commented 1 month ago

Hi @FantaMagier, it seems your log cut out key information. I see the 200 success response the SDK makes to fetch in app messages from the server. I don't see the 500 error.