Appboy / appboy-ios-sdk

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

Device ID returning empty string #322

Closed RichP closed 2 years ago

RichP commented 2 years ago

Using latest version of the braze SDK via Swift Packae Manager in Xcode 13 Appboy.sharedInstance()?.getDeviceId() returns nil.

Happening for all iOS versions and all devices

lowip commented 2 years ago

Hi @RichP,

We are unable to reproduce this issue on our side.

Also please note that the SDK is not compatible with App Clips and using it in that context will lead to the same issue you're experiencing.

RichP commented 2 years ago

Hi @lowip Our previous integration was using Cocoapods. We switched over from using Cocoapods to SPM.

The integration is very basic we just call in appdidfinishlaunchingwithoptions

Appboy.start(withApiKey: brazeAPI, in: UIApplication.shared, withLaunchOptions: launchOptions, withAppboyOptions: [ABKEnableAutomaticLocationCollectionKey: true])

Register for push otifcations

in the callback we query

Appboy.sharedInstance()?.getDeviceId()

We are using Xcode 13

I have double checked AppBoy is initialised

(lldb) po appboySI ▿ Optional

(lldb) po appboySI?.getDeviceId() ▿ Optional

Also querying the identifierForVendor does work

(lldb) po UIDevice.current.identifierForVendor ▿ Optional ▿ some : 61C38C73-135C-4548-9D86-994B70E1659D

Are these not supposed to be the same value?

lowip commented 2 years ago

Hi @RichP,

Can you verify that the flag -ObjC is set. This was done automatically by CocoaPods but is a manual step with SPM (see our integration docs).

RichP commented 2 years ago

yes this flag is set

lowip commented 2 years ago

Hi @RichP,

I've tried replicating your integration but was still unsuccessful in triggering the issue (see AppDelegate.swift). If you are able to provide a minimal sample project with the issue it would be a great help.

In the meantime, can you post the output of:

nm -a <path_to_app_binary> | grep abk_isEmpty

path_to_app_binary here represents the patch to the actual binary inside the .app product (either from archiving your project or from the derived data directory)

The output should resemble:

00000001000cb218 t -[NSArray(IsEmpty) abk_isEmpty]
00000001000cb218 - 01 0000   FUN -[NSArray(IsEmpty) abk_isEmpty]
00000001000cb254 t -[NSDictionary(IsEmptyAndMerge) abk_isEmpty]
00000001000cb254 - 01 0000   FUN -[NSDictionary(IsEmptyAndMerge) abk_isEmpty]
00000001000cb68c - 01 0000   FUN -[NSString(IsEmpty) abk_isEmpty]
00000001000cb68c t -[NSString(IsEmpty) abk_isEmpty]
RichP commented 2 years ago

The above produces no result

RichP commented 2 years ago

Hi @lowip I found the problem. I only added AppboyUI and AppboyPushStory. The documentation says:

"Includes AppboyKit automatically." for AppboyUI

It looks like even with the -ObjC linker flag something isn't getting linked if you just add AppboyUI from the SPM package selector. Going in to Build Phases and manually adding AppboyKit allows getDeviceID() to return a value.

hokstuff commented 2 years ago

Hi @RichP,

Thanks for posting your issue here. It looks like the code for our SDK was not linked correctly when you were experiencing issues. We have not been able to reproduce this on our end when using a fresh codebase and importing AppboyUI and AppboyPushStory, and we recommend re-following the SPM integration docs if you continue to have issues to ensure you have the proper integration.

Since it appears you have solved it on your end, I will close out this issue - thank you!