This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch 
pr-ios-set-callback-id-only-on-target-blank
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git

commit b4e678677b2fb35c0f59c63932e2b4da658a6338
Author: Manuel Beck <[email protected]>
AuthorDate: Tue May 5 11:05:18 2026 +0200

    fix(ios): set `callbackId` only on target=_blank
    
    - The `callbackId` would be overwritten, if the InAppBrowser is called with 
target=_system from a InAppBrowser event callback, like `beforeload`, to open 
links in an external browser. The documentation also states that the reference 
to the `InAppBrowser` window is set, when the target is set to `'_blank'` only.
---
 src/ios/CDVWKInAppBrowser.m | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index 92a35b4..a476bf0 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -76,26 +76,32 @@
 - (void)open:(CDVInvokedUrlCommand *)command
 {
     CDVPluginResult *pluginResult;
-
     NSString *url = [command argumentAtIndex:0];
     NSString *target = [command argumentAtIndex:1 
withDefault:kInAppBrowserTargetSelf];
     NSString *options = [command argumentAtIndex:2 withDefault:@"" 
andClass:[NSString class]];
 
-    self.callbackId = command.callbackId;
-
     if (url != nil) {
-        NSURL *baseUrl = [self.webViewEngine URL];
-        NSURL *absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] 
absoluteURL];
+        NSURL *absoluteUrl = [[NSURL URLWithString:url
+                                     relativeToURL:[self.webViewEngine URL]] 
absoluteURL];
 
         if ([self isSystemUrl:absoluteUrl]) {
             target = kInAppBrowserTargetSystem;
         }
 
+        // target=_self - Open in Cordova WebView
         if ([target isEqualToString:kInAppBrowserTargetSelf]) {
             [self openInCordovaWebView:absoluteUrl withOptions:options];
+            
+            // target=_system - Open external
         } else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
             [self openInSystem:absoluteUrl];
-        } else { // _blank or anything else
+            
+            // target=_blank or anything else, open in in-app browser
+        } else {
+            // Only set the command callback id here
+            // Don't set or overwrite it when target _system or _self is 
called, cause this will
+            // not invoke an in-app browser instance
+            self.callbackId = command.callbackId;
             [self openInInAppBrowser:absoluteUrl withOptions:options];
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to