Skip to content

Conversation

@perarnaudalain
Copy link

Fix issue where nil optional values were incorrectly converted to empty strings ("") when passed through the React Native → Objective-C → Swift bridge. Now properly preserves nullability.

…ty strings ("") when passed through the React Native → Objective-C → Swift bridge. Now properly preserves nullability.
@lorenc-tomasz
Copy link
Contributor

Good point :)

@lorenc-tomasz
Copy link
Contributor

I suggest:

    @objc(setCustomDimension:withValue:withResolver:withRejecter:)
    func setCustomDimension(index: NSNumber, value: String?, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
        guard let tracker = self.tracker else {
            reject("not_initialized", "Matomo not initialized", nil)
            return
        }

        if let unwrappedValue = value {
            tracker.setDimension(unwrappedValue, forIndex: index.intValue)
        } else {
            tracker.remove(dimensionAtIndex: index.intValue)
        }
        
        resolve(nil)
    }

@lorenc-tomasz
Copy link
Contributor

Fixed within: #7

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

Successfully merging this pull request may close these issues.

2 participants