Handler of showPreferencesForExtensionWithIdentifier method getting called multiple times

I have a Mac application.

This app contains safari app extension.


If safari app extension has not been enabled already, following method is executed to show safari preferences screen (Extensions tab) to user.


[SFSafariApplication showPreferencesForExtensionWithIdentifier:<SafariExtensionIdentifier> completionHandler:^(NSError *error) {

[self performSelectorOnMainThread:@selector(showAlertToEnableExtension) withObject:nil waitUntilDone:NO];

}];


- (void)showAlertToEnableExtension {

NSAlert *alert = [[[NSAlert alloc] init] autorelease];

[alert setMessageText:@"Please enable safari app extension"];

[alert runModal];

}


The alert (that notifies user to enable extension) is popping up multiple times.

Can anyone please let me know why do I get multiple alert popups.