Appboy / appboy-ios-sdk

Public repo for the Braze iOS SDK
https://www.braze.com
Other
165 stars 142 forks source link

App crash - appboy-ios-sdk integration #236

Closed chun92 closed 4 years ago

chun92 commented 4 years ago

Report

After we added appboy-ios-sdk to our project, some users reported app crash. The crash logs indicates that crash point is related to appboy sdk, but we couldn't understand what is problem exactly. Currently, the crash occurs rarely so we are not able to reproduce the crash and analyze the reason.

image

It's happening in variety of os version, devices.

Some additional points we consider are:

Describe your environment.

Info Value
Platform Name ios, ipad
Platform Version many versions
SDK Version 3.22.0
Integration Method cocoapods
Xcode Version Xcode 11.4.1
Repro rate sometimes 0.3%

What did you do?

What did you expect to happen?

Braze SDK is integrated properly and creating sessions.

What happened instead?

Braze SDK makes crashes in rare case.

Steps to reproduce

Code Snippet

So many codes.. But I wonder some mistaking points make these crash.

    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
      UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
      center.delegate = self;
      UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
      if (@available(iOS 12.0, *)) {
      options = options | UNAuthorizationOptionProvisional;
      }
      [center requestAuthorizationWithOptions:options
                            completionHandler:^(BOOL granted, NSError * _Nullable error) {
                              [[Appboy sharedInstance] pushAuthorizationFromUserNotificationCenter:granted];
      }];
      [[UIApplication sharedApplication] registerForRemoteNotifications];
    } else {
      UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound) categories:nil];
      [[UIApplication sharedApplication] registerForRemoteNotifications];
      [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    }

We call requestAuthorizationWithOptions:options & registerForRemoteNotifications one more time after this code snippet. Does it affect to app crash?

Are you doing any feature customizations that may relate to the issue? Can you share the code snippet?

Project that demonstrates the issue

https://apps.apple.com/kr/app/bermuda-random-live-video-chat/id1217714999?l=en

But currently we removed sdk from project, so you can't see the problem.

If you need more information to solve this issue, please tell us. We will provide the information as possible.

Bucimis commented 4 years ago

@chun92 we have a tentative fix for this crash, we're planning to release it in our next release. We'll let you know when that happens.

hokstuff commented 4 years ago

Hi @chun92,

We have released this fix in our latest official release of our SDK - you can find it here.

Thanks!