Skip to content

setSiftConfig not properly setting disallowCollectingLocationData in Android #31

@chriszipdev

Description

@chriszipdev

When asking for precise location permission on Android, app would crash when user selects allow once or allow while using. (not an issue on IOS)

Current function

@ReactMethod
    fun setSiftConfig(accountId: String, beaconKey: String, disallowCollectingLocationData: Boolean,
                      serverUrlFormat: String) {
        siftConfig = if (TextUtils.isEmpty(serverUrlFormat)) {
          Sift.Config.Builder()
            .withAccountId(accountId)
            .withBeaconKey(beaconKey)
            .build()
        } else {
          Sift.Config.Builder()
            .withAccountId(accountId)
            .withBeaconKey(beaconKey)
            .withServerUrlFormat(serverUrlFormat)
            .build()
        }
        Sift.open(reactApplicationContext, siftConfig)
        Sift.collect()
    }

setSiftConfig seems to be missing the .withDisallowLocationCollection(disallowCollectingLocationData) chained method when calling .Builder

When I added that everything worked as expected

Suggested change

@ReactMethod
    fun setSiftConfig(accountId: String, beaconKey: String, disallowCollectingLocationData: Boolean,
                      serverUrlFormat: String) {
        siftConfig = if (TextUtils.isEmpty(serverUrlFormat)) {
          Sift.Config.Builder()
            .withAccountId(accountId)
            .withBeaconKey(beaconKey)
            .withDisallowLocationCollection(disallowCollectingLocationData)
            .build()
        } else {
          Sift.Config.Builder()
            .withAccountId(accountId)
            .withBeaconKey(beaconKey)
            .withServerUrlFormat(serverUrlFormat)
            .withDisallowLocationCollection(disallowCollectingLocationData)
            .build()
        }
        Sift.open(reactApplicationContext, siftConfig)
        Sift.collect()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions