Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. iOS SMS window always stays active and it is impossible to cancel it on iPhone
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 389 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kuzulis
    Qt Champions 2020
    wrote on last edited by
    #1

    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()
    {
        QDesktopServices::setUrlHandler(QLatin1String(INSTAGRAM_SCHEME),
                                        this, "handleInstagramUrl");
    
        QDesktopServices::setUrlHandler(QLatin1String(SMS_SCHEME),
                                        this, "handleSmsUrl");
    }
    
    void ExtendedUrlHandler::unregisterSchemes()
    {
        QDesktopServices::unsetUrlHandler(QLatin1String(INSTAGRAM_SCHEME));
        QDesktopServices::unsetUrlHandler(QLatin1String(SMS_SCHEME));
    }
    
    ...
    

    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)
            return;
    
        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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

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

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved