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

Investigate push activation not completing on iOS when running in release configuration #276

Closed
ben-xD opened this issue Dec 6, 2021 · 1 comment · Fixed by #277
Closed
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@ben-xD
Copy link
Contributor

ben-xD commented Dec 6, 2021

When running the application in release mode, the device fails to complete activation when it first launches. The last event in the state machine is a transition from {{NotActivated}} to {{WaitingForPushDeviceDetails}}. A workaround would be to close and relaunch the app. Once relaunched, activation/deactivation works.

{code}
2021-12-06 15:00:34.685283+0700 Runner[21776:7802732] DEBUG: ARTPushActivationStateMachine: transition: ARTPushActivationStateNotActivated -> ARTPushActivationStateWaitingForPushDeviceDetails
{code}
To reproduce it:

  • Run the example app using either
    ** {{flutter run --dart-define=ABLY_API_KEY=$ABLY_API_KEY --release}}.
    ** Xcode "release" configuration and debug executable unchecked (see screenshot)
    !https://user-images.githubusercontent.com/24711048/144826023-3348d069-3482-4c32-9511-98a32d3a17d8.png|CleanShot 2021-12-06 at 09 58 04!
  • Attempt to activate the device by scrolling down to the "Push Notifications" sliver of the scroll view, and press "Activate"
  • You should notice nothing happening. This is because the Future does not complete, because Ably Cocoa never calls back the {{result}} in the following code:
    public func didActivateAblyPush(_ error: ARTErrorInfo?) {
    defer {
    flutterResultForActivate = nil
    }
    methodChannel.invokeMethod(AblyPlatformMethod_pushOnActivate, arguments: error, result: nil)
    if let result = flutterResultForActivate {
    result(error)
    } else {
    print("Did not return a value asynchronously because flutterResultForActivate was nil. The app might have been restarted since calling activate.")
    }
    }

Other notes:

  • This only happens on iOS
  • Other platform methods are working (e.g. connect realtime).

h1. Problem?
This requires further investigation.

This might it is an Ably Cocoa, specifically an Activation State Machine issue, potentially a race condition which occurs when the app runs faster (e.g. in release mode).

@ben-xD ben-xD added the bug Something isn't working. It's clear that this does need to be fixed. label Dec 6, 2021
@ben-xD
Copy link
Contributor Author

ben-xD commented Dec 6, 2021

After further investigation, it looks like it is because the APNs token is not provided to the app early enough in some cases, and the realtime and rest clients are instantiated without it.

To test this out, use:

  ably_flutter:
    git:
      url: git://github.com/ably/ably-flutter.git
      ref: 4685ad628509ca4261c1a283fdc2c90a8fc2cdd0 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging a pull request may close this issue.

1 participant