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

Crash on AWSMobileClient when initialising at runtime. #5458

Closed
RuiAAPeres opened this issue Oct 29, 2024 · 8 comments
Closed

Crash on AWSMobileClient when initialising at runtime. #5458

RuiAAPeres opened this issue Oct 29, 2024 · 8 comments
Labels
bug Something isn't working mobile client Issues related to AWSMobileClient

Comments

@RuiAAPeres
Copy link

RuiAAPeres commented Oct 29, 2024

State your question

We are currently initialising AWPinpoint dynamically (i.e. without the use of JSON files). We do this, because the configuration is dependant on a few conditions that are only available at a later point. We do the following:

let localConfiguration = AWSConfiguration.configuration

let credentialsProvider = AWSCognitoCredentialsProvider(regionType: localConfiguration.cognitoPoolRegion.toAWSRegionType,
                                                                identityPoolId: localConfiguration.cognitoPoolId)

let configuration = AWSServiceConfiguration(region: localConfiguration.pinpointRegion.toAWSRegionType,
                                                    credentialsProvider: credentialsProvider)

AWSServiceManager.default().defaultServiceConfiguration = configuration
pinpointConfiguration = AWSPinpointConfiguration(appId: localConfiguration.pinpointAppId, launchOptions: launchOptions)

/// later on:
pinpoint = configuration.pinpoint /// AWSPinpoint
pinpointAnalyticsClient = configuration.analyticsClient /// AWSPinpointAnalyticsClient

My AWSConfiguration has the following shape:

struct AWSConfiguration {
    let cognitoPoolId: String
    let cognitoPoolRegion: String
    let pinpointAppId: String
    let pinpointRegion: String
}

At a later point, we call this:

AWSMobileClient.default().interceptApplication(application, didFinishLaunchingWithOptions: options)

The above call works fine in DEBUG mode, but it's crashing in RELEASE with the following:

Thread 1: "The service configuration is `nil`. You need to configure `awsconfiguration.json` or `Info.plist` before using this method."
image

This is how our awsconfiguration.json looked (before removing it):

{
  "UserAgent": "MobileHub/1.0",
  "Version": "1.0",
  "CredentialsProvider": {
    "CognitoIdentity": {
      "Default": {
        "PoolId": "eu-west-xyz",
        "Region": "eu-west-1"
      }
    }
  },
  "IdentityManager": {
    "Default": {}
  },
  "PinpointAnalytics": {
    "Default": {
      "AppId": "pyx",
      "Region": "us-east-1"
    }
  },
  "PinpointTargeting": {
    "Default": {
      "Region": "us-east-1"
    }
  }
}

Question:

  1. Is there something special happening in Release?
  2. Do I even need to call AWSMobileClient.default().interceptApplication? We only use AWSPinpoint.

Which AWS Services are you utilizing?

I am using AWSPinpoint.

Provide code snippets (if applicable)

Environment(please complete the following information):

  • SDK Version: 2.37.1
  • Dependency Manager: SPM
  • Swift Version : 5.0

Device Information (please complete the following information):

  • Device: Simulator iPhone Pro
    • iOS Version: iOS 17.5
@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Oct 29, 2024
@edisooon edisooon added bug Something isn't working pinpoint Issues related to AWS Pinpoint and removed pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Oct 30, 2024
@edisooon
Copy link
Member

Hi @RuiAAPeres, thank you for submitting this ticket! One of our team members will do some investigation on this as soon as possible.
Meanwhile, could you provide more log information from the crashes? This might help us identify the issue more easily.

@ruisebas
Copy link
Member

Hi @RuiAAPeres!

AWSMobileClient.interceptApplication(_:didFinishLaunchingWithOptions:) is deprecated and was actually meant to be removed altogether way back in 2.11.0, but since it's still defined in the Objective-C interface you can still access it.

We apologize for the confusion/inconvenience this caused, and we will take notice to remove these outdated methods soon.

To answer your question: no, you should not use that method. Instead, what you should call from your AppDelegate is the AWSMobileClient.initialize method, as described in the documentation page.

Please update your code and let us know if you're still experiencing the crash.

@ruisebas ruisebas added mobile client Issues related to AWSMobileClient and removed pinpoint Issues related to AWS Pinpoint labels Oct 31, 2024
@RuiAAPeres
Copy link
Author

Hi @ruisebas, appreciate the reply. I guess my question is: why? As in, what's the benefit of calling that method if I am only using AWSPinpoint? From my tests, without using AWSMobileClient at all, I am still able to send events.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Oct 31, 2024
@ruisebas
Copy link
Member

It depends on how your backend is configured. If you're not going to use Auth-related operations nor rely on them to submit events to Pinpoint, then it's probably ok to avoid using AWSMobileClient altogether.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Oct 31, 2024
@RuiAAPeres
Copy link
Author

I would like you to expand on that probably ok. Is it going to be a problem, or not? 😅 I am currently not using any auth-related operations. We only use AWSPinpoint.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Oct 31, 2024
@ruisebas
Copy link
Member

Officially, our guidance is to use both AWSMobileClient and AWSPinpoint when adding Analytics in this SDK.

But it depends on your use case and how you've configured your backend. If you don't authenticate your users at all during your app's lifecycle and your Pinpoint application accepts events just fine, then I see no reason to initialize AWSMobileClient.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Oct 31, 2024
@RuiAAPeres
Copy link
Author

Thank you @ruisebas. I will close this issue for now. I will re-open (or create a new one) if we have issues.

Outcome: we will use the AWSPinpoint framework on its own, without using AWSMobileClient.

Copy link

github-actions bot commented Nov 7, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mobile client Issues related to AWSMobileClient
Projects
None yet
Development

No branches or pull requests

3 participants