react-native-spotlight-search icon indicating copy to clipboard operation
react-native-spotlight-search copied to clipboard

getInitialSearchItem return empty initialIdentifier ignore the handleContinueUserActivity value

Open luatnd opened this issue 5 years ago • 4 comments

Hi, this lib comes in handy, but I struggle with a bug:

I just debug the case:

self.initialIdentifier has value in handleContinueUserActivity:

self.initialIdentifier = uniqueItemIdentifier; // set break point here and got the correct value
- (void)handleContinueUserActivity:(NSUserActivity *)userActivity {
    NSString *uniqueItemIdentifier = userActivity.userInfo[CSSearchableItemActivityIdentifier];
    
    if (!uniqueItemIdentifier) {
        return;
    }

    self.initialIdentifier = uniqueItemIdentifier;
    
    if (!self.hasListeners) {
        return;
    }
    
    [self sendEventWithName:kSpotlightSearchItemTapped body:uniqueItemIdentifier];
}

But self.initialIdentifier became nil here:

RCT_EXPORT_METHOD(getInitialSearchItem:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
    resolve(self.initialIdentifier);
}

It leads to undefined on JS:

SpotlightSearch.getInitialSearchItem().then(console.log);

luatnd avatar Dec 22 '20 09:12 luatnd

This is also returning undefined in my case: "react-native-spotlight-search": "^2.0.0" "react-native": "0.64.1"

deepak-ofb avatar Jun 14 '21 15:06 deepak-ofb