Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何以编程方式打开WhatsApp,然后返回到我的应用程序?_Ios_Objective C_Cocoa Touch_Whatsapp - Fatal编程技术网

Ios 如何以编程方式打开WhatsApp,然后返回到我的应用程序?

Ios 如何以编程方式打开WhatsApp,然后返回到我的应用程序?,ios,objective-c,cocoa-touch,whatsapp,Ios,Objective C,Cocoa Touch,Whatsapp,在我的应用程序中,我需要通过WhatsApp发送链接。我就是这样做的: NSString* link = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)resource.shareURL.absolu

在我的应用程序中,我需要通过WhatsApp发送链接。我就是这样做的:

 NSString* link = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,
                                                                                   (CFStringRef)resource.shareURL.absoluteString,
                                                                                   NULL,
                                                                                   CFSTR("!*'();:@&=+$,/?%#[]"),
                                                                                   kCFStringEncodingUTF8));

            NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@", link];
            NSURL * whatsappURL = [NSURL URLWithString:urlWhats];

            if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
                [[UIApplication sharedApplication] openURL: whatsappURL];
            } else {
                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Unknown error"
                                                                 message:@"Can't open Whatsapp"
                                                                delegate:nil
                                                       cancelButtonTitle:@"OK"
                                                       otherButtonTitles:nil];
                [alert show];
            }

但问题是,消息发送后,它不会自动返回到我的应用程序。用户需要手动返回应用程序。那么,我如何让它返回到我的应用程序?有可能吗

这是不可能的。理论上,实现这一点的唯一方法是在whatsapp的完成处理程序中为您的应用程序发送URI。但是,whatsapp scheme不支持此类功能,因此无法强制它在发送消息后打开您的应用程序。

这是不可能的。理论上,实现这一点的唯一方法是在whatsapp的完成处理程序中为您的应用程序发送URI。然而whatsapp方案不支持此类内容,因此无法强制其在发送消息后打开您的应用程序。

这只能在whatsapp支持x-callback-url方案并在您完成后返回到您的应用程序时起作用。这只能在whatsapp支持x-callback-url方案并在发送消息后返回到您的应用程序时起作用你在他们那里完蛋了。