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

App Crash when Advertisement tracking "Allow Tracking" in iOS14 #452

Closed
tpeodndyy opened this issue Aug 18, 2020 · 7 comments
Closed

App Crash when Advertisement tracking "Allow Tracking" in iOS14 #452

tpeodndyy opened this issue Aug 18, 2020 · 7 comments

Comments

@tpeodndyy
Copy link

My project and other similar projects are facing the crash issue when app "Allow Tracking" and get ATTrackingManager.AuthorizationStatus.authorized from AppTrackingTransparency.

The crash happen once we start initialize Adjust SDK by Adjust.appDidLaunch(adjustConfig) then the app crash with message "Message from debugger: Terminated due to signal 9"

I have also tried setting the config .allowIdfaReading = false but still face a crash.

I also tried this with new example project to prove that this happen and it's. Just simple project and adding code below

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        
        ATTrackingManager.requestTrackingAuthorization { status in
            let adjustConfig = ADJConfig(appToken: Constant.adjustTrackerToken, environment: ADJEnvironmentSandbox)
            Adjust.appDidLaunch(adjustConfig)
        }
        return true
}

If select "Allow Tracking", App will crash and even next time relaunch app it will also crash due to authorization status is already authorized. However if select "Do not allow tracking" App won't crash and Adjust will initialize correctly.

@uerceg
Copy link
Contributor

uerceg commented Aug 18, 2020

Hi @tpeodndyy

We're releasing SDK which will support current state of things in iOS 14 beta soon, but still curious about this. So it's always reproducible for you? Any chance to get crash stack trace?

Cheers

@tpeodndyy
Copy link
Author

hi @ugi

That's great to hear, I am looking forward to that.

The crash is happening 100% once allow the tracking and for both device and simulator.

Sorry I forgot to provide more information regarding to development environment too.
I am currently on Xcode 12 beta 4 (and several simulator along with the Xcode)
Testing device is iPhoneXR iOS12 beta 4

I have tried to find the way to get stack trace but cannot get any thing. Only crash happen with debug message
"Message from debugger: Terminated due to signal 9"

@uerceg
Copy link
Contributor

uerceg commented Aug 18, 2020

Thanks for the info. Will try to see if we can reproduce it our end. Will keep you posted.

@uerceg
Copy link
Contributor

uerceg commented Aug 18, 2020

@tpeodndyy One more time thanks for reporting and as far as the issue itself is concerned - wow. After a bit of debugging I noticed that app gets terminated in moment when attempt to communicate with iAd framework is being made. And literally it happens as you noticed it - only if state of consent is ATTrackingManagerAuthorizationStatusAuthorized. If you answer that you don't want to be tracked (ATTrackingManagerAuthorizationStatusDenied), things work well. They actually seem to be working fine in any state other than ATTrackingManagerAuthorizationStatusAuthorized.

I have tried this in app which doesn't even use our SDK. This is how code looks like:

#import "AppDelegate.h"
#import <iAd/iAd.h>
#import <AppTrackingTransparency/AppTrackingTransparency.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    if (@available(iOS 14, *)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            switch (status) {
                case ATTrackingManagerAuthorizationStatusAuthorized:
                    NSLog(@"ATTrackingManagerAuthorizationStatusAuthorized");
                    break;
                case ATTrackingManagerAuthorizationStatusDenied:
                    NSLog(@"ATTrackingManagerAuthorizationStatusDenied");
                    break;
                case ATTrackingManagerAuthorizationStatusRestricted:
                    NSLog(@"ATTrackingManagerAuthorizationStatusRestricted");
                    break;
                case ATTrackingManagerAuthorizationStatusNotDetermined:
                    NSLog(@"ATTrackingManagerAuthorizationStatusNotDetermined");
                    break;
            }
        }];
    } else {
        // Fallback on earlier versions
    }
    
    [[ADClient sharedClient] requestAttributionDetailsWithBlock:^(NSDictionary<NSString *,NSObject *> * _Nullable attributionDetails, NSError * _Nullable error) {
        NSLog(@"made it!");
    }];
    
    return YES;
}

If you launch the app for the first time ever, communication with iAd framework will be attempted right away, so status of consent at that moment will be ATTrackingManagerAuthorizationStatusNotDetermined and things work. And now if you Allow Tracking and restart the app - same code causes app to be terminated. And if you retry this with not allowing to be tracked, things work fine. 🤷

So this is reproducible by solely using Apple's API (our SDK uses this as well) and that's the problem. I filed bug report to Apple and you can also find description in here. Appears to me that maybe things don't really work well in this scenario in iOS 14 which is still beta, but let's see what Apple's reply will say.

And back to finding a way how to test our SDK with iOS 14 - if iAd framework and Apple Search Ads are not something you care about while testing, you can call following method on our configuration object:

[adjustConfig setAllowiAdInfoReading:NO];

and that will cause SDK to completely ignore iAd framework and not interact with it. With that option set, you should not see app being terminated. This will unfortunately be the case for our upcoming release as well (will be stated in release notes).

In case you have any further questions, feel free to ask.

Cheers

@uerceg
Copy link
Contributor

uerceg commented Aug 19, 2020

And mystery solved. Bit thanks to Apple for lightning fast response.

Indeed it seems to be a bug on Apple's end, but it is fixed in iOS 14 beta 5 (just tested, seems to be working just fine). So, as a final response (and a warning note we'll add in our tomorrow's CHANGELOG and release notes): Give it a shot with iOS 14 beta 5 (or later) and things should work.

Cheers

@evaldsurtans
Copy link

In my case I was missing required key in Info.plist - without it, app just crashes when launching request

Info_plist

@osmaneser
Copy link

osmaneser commented Sep 8, 2021

In my case I was missing required key in Info.plist - without it, app just crashes when launching request

Info_plist

I was having thesame problem. I fixed this way. Thank you @evaldsurtans

EDIT:
Also I am using IOS 14 Beta 5 version already.

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

4 participants