Important: Please read the Qt Code of Conduct -

iOS SMS window always stays active and it is impossible to cancel it on iPhone

  • Qt Champions 2020

    Hi all.

    I need to register an own URL handler which handles my custom URL scheme as 'smsto'. In this scheme I use the custom URL which allows to transfer a custom pre-defined SMS body.

    For this purpose I have created my URL handler ExtendedUrlHandler with following code:

    void ExtendedUrlHandler::registerSchemes()
                                        this, "handleInstagramUrl");
                                        this, "handleSmsUrl");
    void ExtendedUrlHandler::unregisterSchemes()

    And then following method launch the native iPhone SMS dialer:

    void ExtendedUrlHandler::handleSmsUrl(const QUrl &url)
        qCWarning(EXTURL_HANDLER) << "Start pase url:" << url;
        QString smsScheme;
        QString smsPhone;
        QString smsBody;
        const auto isParsed = parseSmsUrl(url, &smsScheme, &smsPhone, &smsBody);
        if (!isParsed)
        UIWindow *window = qt_apple_sharedApplication().keyWindow;
        const auto messageViewController = [[[MFMessageComposeViewController alloc] init] autorelease];
        if ([MFMessageComposeViewController canSendText]) {
            messageViewController.body = smsBody.toNSString();
            messageViewController.recipients = [NSArray arrayWithObjects:smsPhone.toNSString(), nil];
            messageViewController.messageComposeDelegate = nil;
            [window.rootViewController presentViewController:messageViewController animated:YES completion:nil];

    But a problem that I can't exit from the SMS dialer back to my application UI. It always show the SMS dialer, even I click to 'Cancel' button.

    Could someone point me to the right way?

  • Qt Champions 2020

    I fixed this now. Need just to use a delegate where rectore the application's UIView, see for example this.

Log in to reply