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

Error: You need to be activate Adapty once #124

Closed
hasimyerlikaya opened this issue Nov 22, 2024 · 8 comments
Closed

Error: You need to be activate Adapty once #124

hasimyerlikaya opened this issue Nov 22, 2024 · 8 comments

Comments

@hasimyerlikaya
Copy link

Even though I check the status with Adapty().isActivated() before activation, Adapty().activate(...) returns error 3005.

The Adapty().isActivated() method returns false.

It seems like it’s not working correctly.

adapty_flutter: ^3.2.2
Flutter: 3.24.5 (stable)
Dart: 3.5.4 (stable)
iOS: 18.1.1

Error:
(code: 3005, message: You need to be activate Adapty once, detail: {"detail":"AdaptyError.activateOnceError([3.2.0]: Adapty\/Adapty+Activate.swift#65)","adapty_code":3005,"message":"You need to be activate Adapty once"})

late final initJob = JobResultAsync<bool>(
    () async {
      if (isActivated) {
        return true;
      }

      final nativeCheck = await Adapty().isActivated();
      if (nativeCheck) {
        return true;
      }

      await Adapty().activate(
        configuration: AdaptyConfiguration(
          apiKey: AppArgs.adaptyKey,
        ),
      );

      return true;
    },
    onError: (result) {
      print(result.error);
    },
  );
@atoka93
Copy link

atoka93 commented Nov 28, 2024

It also happens for when running on iOS: once I added the API key to Info.plist file, it started happening only on hot restarts even though I ran flutter clean after.

@ferhatAksoy
Copy link

Having same issue

@obenkucuk
Copy link

After updating to version 3+, I started experiencing the same issue.

@ibrahimdevs
Copy link

@x401om , @vladd-g we're experiencing the same issue on Android. When we first install, it is working normally. But when you perform hot restart, adapty prints this error.

E/Adapty_v3.1.0(29444): ERROR: Adapty was already activated. If you want to provide new customerUserId, please call 'identify' function instead.

We tried to check with isActivated but no luck. I think in native side, it continue to keep last activation even if hot restart happens.

@ismail-go
Copy link

Having the same issue too

@obenkucuk
Copy link

@x401om , @vladd-g we're experiencing the same issue on Android. When we first install, it is working normally. But when you perform hot restart, adapty prints this error.

E/Adapty_v3.1.0(29444): ERROR: Adapty was already activated. If you want to provide new customerUserId, please call 'identify' function instead.

We tried to check with isActivated but no luck. I think in native side, it continue to keep last activation even if hot restart happens.

@x401om , @vladd-g we're experiencing the same issue on Android. When we first install, it is working normally. But when you perform hot restart, adapty prints this error.

E/Adapty_v3.1.0(29444): ERROR: Adapty was already activated. If you want to provide new customerUserId, please call 'identify' function instead.

We tried to check with isActivated but no luck. I think in native side, it continue to keep last activation even if hot restart happens.

I have checked that isActivated method and it calls this function on native side. Still, it returns incorrect answer.

@x401om
Copy link
Collaborator

x401om commented Dec 5, 2024

Hi everyone! Thank you for your patience. We’ve just released version 3.2.3, which ensures that isActivated correctly returns the native SDK activation status.

Please make sure to use Adapty().setupAfterHotRestart() and AdaptyUI.setupAfterHotRestart(observer:) after a hot restart so the plugin can properly receive messages from the native side.

I assume you’ll implement the activation flow something like this:

import 'package:adapty_flutter/adapty_flutter.dart';
import 'package:flutter/foundation.dart';

Future<void> activateAdaptyIfNeeded() async {
    try {
        var isActivated = false;

        // Please consider not using this in production to avoid any unwanted effects
        if (kDebugMode) {
            isActivated = await Adapty().isActivated();
        } else {
            isActivated = false;
        }

        if (!isActivated) {
            await Adapty().activate(configuration: <YOUR_CONFIGURATION_OBJECT>);
            await AdaptyUI().activate(observer: <YOUR_OBSERVER_OBJECT>);
        } else {
            Adapty().setupAfterHotRestart();
            AdaptyUI().setupAfterHotRestart(observer: this);
        }
    } catch (e) {
        // handle the error
    }
}

@sajithlascade
Copy link

sajithlascade commented Jan 6, 2025

The method 'setupAfterHotRestart' isn't defined for the type 'AdaptyUI'.

adapty_flutter: ^3.3.0

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

8 participants