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

Custom Http headers are not applied on non-queued requests on iOS #298

Open
sbatezat opened this issue Nov 12, 2024 · 38 comments
Open

Custom Http headers are not applied on non-queued requests on iOS #298

sbatezat opened this issue Nov 12, 2024 · 38 comments

Comments

@sbatezat
Copy link
Contributor

sbatezat commented Nov 12, 2024

AvailableFeedbackWidgets not working anymore on iOS

final feedbackWidgets = await Countly.getAvailableFeedbackWidgets();
final empty = feedbackWidgets.presentableFeedback.isEmpty

empty is returning false on Android (this is ok) and true on iOS

It was working previously and I'm still looking for the root cause...

@sbatezat sbatezat changed the title AvailableFeedbackWidgets not working anymore AvailableFeedbackWidgets not working anymore on iOS Nov 12, 2024
@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Hi @sbatezat,
Thank you for reporting this issue. Could you please print or check the values inside presentableFeedbacks to help us investigate further?

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

presentableFeedbacks is empty, and retrievedWidgets (= await _channel.invokeMethod('getAvailableFeedbackWidgets')) is too

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Thank you for checking that. I’ll investigate this issue and get back to you soon.

@sbatezat
Copy link
Contributor Author

If it helps:

image

@sbatezat
Copy link
Contributor Author

Maybe because, according to this changelog, getFeedbackWidget is deprecated on iOS ?

https://github.com/Countly/countly-sdk-flutter-bridge/pull/285/files#diff-3111fcf07123eea4da5d6438464033e1fbbbedc580067636e09f7da49a4a6a4f

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Good observation! However, since the deprecated method uses the same underlying implementation as getAvailableFeedbackWidgets(), the issue is likely unrelated to that. I’ll continue investigating and update you soon.

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Could you please print or check the values of feedbackWidgets.presentableFeedback on Android as well?

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

It seems possible that the user you're checking on iOS may have already completed or submitted the available feedback, which could be why no new feedback is being retrieved. Could you try testing with a different device ID?

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

Unfortunately, I've got only one iOS device.
What do you mean by "have already completed or submitted the available feedback"?
I have always been able to publish multiple feedback and I've got only one available widget, which has never changed

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Each user has a unique device ID. When feedback is submitted, the server marks it as completed and only returns feedbacks that hasn't been completed yet for that user.

Since you mentioned having only one iOS device, you can try reinstalling the app. This will automatically assign a new device ID if you're not explicitly providing one during initialization or changing it after initialization.

If you want to change the device ID without merging, you can use the changeDeviceId method (which is the recommended approach in your case), as described here:
https://support.countly.com/hc/en-us/articles/34539364044697-Flutter-24-4#h_01H930GAQ682G16Z7M570XKSPD

In new versions we have added setID method for easier handling, as explained here:
https://support.countly.com/hc/en-us/articles/360037944212-Flutter#h_01H930GAQ682G16Z7M570XKSPD

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

When feedback is submitted, the server marks it as completed and only returns feedbacks that hasn't been completed yet for that user.

I've got tons of "multiple" feedback for the same user (i'm setting a custom ID), it's working fine (until now, and just broken only on iOS) and it's "my" expected behavior.

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Could you please try with different device ID?

@sbatezat
Copy link
Contributor Author

Same behavior: a list of available widgets (1) on Android, but an empty list on iOS.

@sbatezat
Copy link
Contributor Author

Could you please print or check the values of feedbackWidgets.presentableFeedback on Android as well?

image

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

It's very weird my users have a unique ID and are using the same widget to send multiple feedback since ever, and you tell me it's not possible.
Maybe we are not talking about the same thing? I'm talking about rating widgets.

image

I don't know if there is other with different rules.

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

There are three types of feedback widgets (Survey, NPS, and Ratings)
Survey and NPS are 1 time only by default, but they can be adjusted to be shown all the time.
On the other hand Rating widgets are shown all the time.
I have again checked Rating widget on iOS and its working for me.

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

On the other hand Rating widgets are shown all the time.

Ok! All good on that side 👍

With the same source code, it's working on Android and not on iOS for my app.
I'm wondering about this PR #284 if the available widget request is not done with custom header on iOS for any reason. But there is no error message apparently so I doubt it's the issue.

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Rating widgets also have the option to set targeting users, could you please verify the targeting users of your rating widget on dashboard?

@sbatezat
Copy link
Contributor Author

It's set on "all users".
Moreover, i'm working with the same id (my email) on both Android & iOS, so it cannot be link to the user part.

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

To help diagnose the issue further, could you please try accessing the following URL in your browser by replacing the placeholders with your actual server URL, app key, and device ID?

https://YOUR_SERVER_URL/o/sdk?method=feedback&app_key=YOUR_APP_KEY&device_id=YOUR_DEVICE_ID

Please check the response using both your iOS and Android device IDs separately and share the results. This will help us understand if the server is returning the correct feedback widgets for each device.

@sbatezat
Copy link
Contributor Author

My device id is the same for both Android & iOS, so I'll have only one result. Here it is:

{
  "result": [
    {
      "_id": "6555368f72ce854e9c0c453d",
      "type": "rating",
      "showPolicy": "afterPageLoad",
      "appearance": {
        "position": "mleft",
        "bg_color": "#123456",
        "text_color": "#fff",
        "text": "Retour d'expérience",
        "size": "m",
        "hideS": true
      },
      "tg": [
        "/"
      ],
      "name": "Donnez-nous votre avis !"
    }
  ]
}

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Great!, response looks ok
Can you please check that URL with the device ID you had changed (without merge) for iOS?

@sbatezat
Copy link
Contributor Author

My device id is the same for both Android & iOS for months

@ijunaid
Copy link
Contributor

ijunaid commented Nov 12, 2024

Would it be possible for you to open your iOS project in Xcode and add a breakpoint at line 506 in the CountlyFeedbacksInternal.m file? Please check and share the values of request and the constructed URL at that point. This will help us verify if the request is being formed correctly.

Screenshot_FeebackInternal

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

The request seems to be fine.

I've found the origin.
My API Management in front of Countly instance is returning 403.

image

There is an error field populated on iOS part but not on Flutter side.

image

I'm looking for request details to see if my custom header (needed by my API Management) is set, but probably not.

@sbatezat
Copy link
Contributor Author

Ok, I can confirm it's an issue with #284

There is a "nil" on NSURLSession.sharedSession.configuration.HTTPAdditionalHeaders...
Updating manually the task like this is working fine:

image

Of course, I've called config.setCustomNetworkRequestHeaders(headers);

@sbatezat
Copy link
Contributor Author

sbatezat commented Nov 12, 2024

@ijunaid could you please confirm it's an iOS issue and ask the iOS team to fix it?

Whatever, I keep this issue opened, as Flutter Countly is using a deprecated method AND do not log iOS error on that case

@ijunaid
Copy link
Contributor

ijunaid commented Nov 13, 2024

@sbatezat, thanks for the update. I’ll discuss this internally with the team and work on fixing the issue.

@ijunaid ijunaid changed the title AvailableFeedbackWidgets not working anymore on iOS Custom Http headers are not applied on non-queued requests on iOS Nov 13, 2024
@sbatezat
Copy link
Contributor Author

@ijunaid do you have any feedback about this? Did the iOS team tell you when they will work on this?
Our feedback feature is down on production because of that... We can't switch back to our previous servers (which doesn't need specific header...) for technical reason :/

@ijunaid
Copy link
Contributor

ijunaid commented Nov 14, 2024

@sbatezat It has already been fixed on the iOS side, after some more testing we will release the iOS
Then, we will update the underlying iOS SDK in Flutter and release it.
Here is the PR for iOS fix:
#298

@sbatezat
Copy link
Contributor Author

Hi @ijunaid
It has been merged last week on staging, do you have any idea about the release date?
Many thanks

@ijunaid
Copy link
Contributor

ijunaid commented Nov 19, 2024

Hi @sbatezat
@turtledreams will guide you better for the release date

@turtledreams
Copy link
Contributor

Thank you @ijunaid <3. Hi @sbatezat, if all goes well this week both iOS and Flutter should be released. But there are some other features holding us back so if they took over at worst next week it should be released.

@sbatezat
Copy link
Contributor Author

Thank you both for these quick answers! Good luck

@sbatezat
Copy link
Contributor Author

Sorry to ask again, is it still planned for this week?
We're waiting for this fix to release our next release and fix related bugs

@turtledreams
Copy link
Contributor

Hi @sbatezat , yes we plan to release today if everything goes according to the plan. We have some new server features for which had to hold back and keep testing.

@turtledreams
Copy link
Contributor

@sbatezat just released 24.11.1

@sbatezat
Copy link
Contributor Author

sbatezat commented Dec 2, 2024

Thanks; I did the update and it's working as expected.
Should we leave the issue open regarding the two remaining points:

as Flutter Countly is using a deprecated method AND do not log iOS error on that case

From #298 (comment)

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

3 participants