[Interest] iOS didFinishLaunchingWithOptions and such

Edward Sutton edward.sutton at subsite.com
Mon Nov 16 14:25:52 CET 2015


> On Nov 14, 2015, at 1:37 PM, Robert Iakobashvili <coroberti at gmail.com> wrote:
>
> Gentlemen,
> For iOS works general cross-platform Qt url handling mechanism.
>
> //
> // Register for: iOS "Open In" file sharing  and for our special file extensions
> //
> QDesktopServices::setUrlHandler("file", this,
> "handle_shared_ios_file_and_app_ext_we_are_registed_for");
>
> Existing Qt iOS delegate calls all URL-handling.

Thanks Robert!

-Ed

>
> Take care.
>
> Regards,
> Robert
>
>
> On Sat, Nov 14, 2015 at 3:09 PM, maitai <maitai at virtual-winds.org> wrote:
>> I finally fixed my problem by running app->exec() much sooner in main.cpp
>> (using a QTimer::singleShot(0, ...) to finished my initialization). It seems
>> that the fact that exec() and eventloop was not started soon enough
>> conflicted somehow with openUrl(), while in a normal situation that was not
>> a problem.
>>
>> Thanks again Edward for your help, that was very helpful.
>>
>> Philippe Lelong
>>
>>
>>
>>
>>
>> Le 13-11-2015 20:17, maitai a écrit :
>>
>> Ok then, I need to review all that it's clear.
>>
>> Thank you a thousand times for your input, it helps a lot to know that it's
>> something wrong with my own code.
>>
>> I'll post back when fixed
>>
>>
>>
>>
>>
>> Le 13-11-2015 20:10, Edward Sutton a écrit :
>>
>>
>> On Nov 13, 2015, at 1:01 PM, maitai <maitai at virtual-winds.org> wrote:
>>
>>> And just to make sure I understand well, if you press your app icon "copy
>>> to MyApp" your app launches and all is fine? If this is the case then the
>>> problem must be on my side obviously
>>
>> Yes. My Qt 5.5 widget app launches splash screen, then app opens the data
>> file displaying the data inside the app.
>>
>> I just powered-off and repeated test. App launched just fine.
>>
>> iPhone 5c, iOS 9.1.
>>
>> Built on Xcode 7.1.1 on OS X 10.10.5
>>
>> -Ed
>>
>>
>>
>>
>>
>> Le 13-11-2015 19:56, Edward Sutton a écrit :
>>
>>
>>
>> On Nov 13, 2015, at 12:50 PM, maitai <maitai at virtual-winds.org> wrote:
>>
>> Thanks Edward for your fast answer.
>>
>>> That is working also if your app is not in the background (i.e not
>>> started)?
>>
>> Yes. Since Qt 5.4 and currently using Qt 5.5.1
>>
>> I just closed my app to make sure.
>>
>> Then I went to iOS mail and opened an email attachment of a file with a
>> *.TSR file extension associated with my application.  The sharing thing
>> opens.  One of the options displayed my app's icon with text "Copy yo MyApp"
>>
>> -Ed
>>
>>
>>
>>
>>
>> Le 13-11-2015 19:42, Edward Sutton a écrit :
>>
>> I am using a pure Qt 5.5.1 iOS widgets app.  Disclaimer: This solution works
>> but may not be the best solution.  Recommendations for a cleaner approach
>> are welcome.
>>
>> Using Qt 5.5.1 I added myApplicationDelegate.mm that posts an fileOpenEvent.
>> It would be nice if this was built into Qt. See below File:
>> myApplicationDelegate.mm.
>>
>> Then I subclass QApplication to include  to add a member variable for my
>> QMainWindowto watch for QEvent::FileOpen and call
>>
>>
>>
>> /// Looks for QFileOpenEvent to implement app file open from
>>
>> /// other apps, for example, Finder on OS X, or Apple Mail on iOS and OS X.
>>
>> ///
>>
>> ///
>>
>> /// \remarks Could this work on Android too?
>>
>> ///
>>
>> /// See file: myApplicationDelegate.mm
>>
>> /// \see myApplicationDelegate.mm.mm
>>
>> ///
>>
>> bool TcmwApplication::event(QEvent* event)
>>
>> {
>>
>>    // iOS receives ApplicationDeactivate, ApllicationStateChange, when Home
>> is pressed
>>
>>    // When iOS user opens Mail file attachment using "Open in TSR",
>> ApplicationActivate event received but NOT QEvent::FileOpen
>>
>>    switch (event->type())
>>
>>    {
>>
>>
>>
>> #if 0 // Why was I calling m_mainWindow.show() here? Android problem?
>>
>>        case QEvent::ApplicationActivate:
>>
>>        {
>>
>>            //clean();
>>
>>            if (false == m_mainWindow.isMinimized())
>>
>>            {
>>
>>                qDebug("m_mainWindow.show()");
>>
>>                // Why was I calling m_mainWindow.show() here? Android
>> problem?
>>
>>                //m_mainWindow.show();
>>
>>            }
>>
>>            return true;
>>
>>        }
>>
>> #endif
>>
>>        case QEvent::FileOpen:
>>
>>        {
>>
>>            // Should file attachments be copied locally as if they were
>> downloaded from a TK?
>>
>>            QString fileName = static_cast<QFileOpenEvent *>(event)->file();
>>
>>            m_mainWindow.openFile(fileName);
>>
>>            return true;
>>
>>        }
>>
>>        default:
>>
>>            break;
>>
>>    }
>>
>>    return QApplication::event(event);
>>
>> }
>>
>> #endif
>>
>>
>>
>> -Ed
>>
>>
>>
>> File: myApplicationDelegate.mm
>>
>>
>> #include <UIKit/UIKit.h>
>>
>>
>>
>> #include <QDebug>
>>
>> #include <QFileOpenEvent>
>>
>>
>>
>>
>>
>> #include "qiosapplicationdelegate.h"
>>
>>
>>
>> /// \category QIOSApplicationDelegate(TcmwApplicationDelegate)
>>
>> /// \abstract A category on QIOSApplicationDelegate to override openURL
>>
>>
>>
>>
>>
>> /// Use the Objective-C category feature to override the openURL method
>>
>> @implementation QIOSApplicationDelegate (TcmwApplicationDelegate)
>>
>>
>>
>> /// Posts a QFileOpenEvent to QCoreApplication when iOS calls openURL.
>>
>> ///
>>
>> /// This allows userto open a TSR file from Apple Mail,
>>
>> /// select "Open in TSR", to launch TSR and pass openURL the
>>
>> /// file to open.
>>
>> ///
>>
>> /// Must add UTExportedTypeDeclarations and CFBundleDocumentTypes to your
>>
>> /// Info.plist for this to work.
>>
>> ///
>>
>> /// Example: Info.plist
>>
>> /// \verbatim
>>
>> ///    <key>UTExportedTypeDeclarations</key>
>>
>> ///    <array>
>>
>> ///        <dict>
>>
>> ///            <key>UTTypeConformsTo</key>
>>
>> ///            <array>
>>
>> ///                <string>public.data</string>
>>
>> ///            </array>
>>
>> ///            <key>UTTypeDescription</key>
>>
>> ///            <string>Tracking Status Report</string>
>>
>> ///            <key>UTTypeIdentifier</key>
>>
>> ///            <string>com.ditchwitch.tsr</string>
>>
>> ///            <key>UTTypeTagSpecification</key>
>>
>> ///            <dict>
>>
>> ///                <key>public.filename-extension</key>
>>
>> ///                <string>tsr</string>
>>
>> ///                <key>public.mime-type</key>
>>
>> ///                <string>public.data</string>
>>
>> ///            </dict>
>>
>> ///        </dict>
>>
>> ///    </array>
>>
>> ///    <key>CFBundleDocumentTypes</key>
>>
>> ///    <array>
>>
>> ///        <dict>
>>
>> ///            <key>CFBundleTypeIconFiles</key>
>>
>> ///            <array>
>>
>> ///                <string>Icon.png</string>
>>
>> ///            </array>
>>
>> ///            <key>CFBundleTypeName</key>
>>
>> ///            <string>Tracking Status Report</string>
>>
>> ///            <key>CFBundleTypeRole</key>
>>
>> ///            <string>Editor</string>
>>
>> ///            <key>LSHandlerRank</key>
>>
>> ///            <string>Owner</string>
>>
>> ///            <key>LSItemContentTypes</key>
>>
>> ///            <array>
>>
>> ///                <string>com.ditchwitch.tsr</string>
>>
>> ///                <string>public.data</string>
>>
>> ///            </array>
>>
>> ///        </dict>
>>
>> ///    </array>
>>
>> /// \endverbatim
>>
>> ///
>>
>> /// See file: tcmwapplication.cpp
>>
>> /// \see tcmwapplication.cpp
>>
>> ///
>>
>> /// \see
>> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html
>>
>> ///
>>
>> - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
>>
>>                                       sourceApplication:(NSString
>> *)sourceApplication
>>
>>                                              annotation:(id)annotation
>>
>> {
>>
>>    Q_UNUSED(application);
>>
>>    Q_UNUSED(annotation);
>>
>>
>>
>>    NSLog(@"sourceApplication: %@",sourceApplication);
>>
>>    NSLog(@"url: %@",url);
>>
>>
>>
>>    QString filePath = QString::fromNSString(url.path);
>>
>>    qDebug("filePath %s", filePath.toLatin1().data());
>>
>>
>>
>>    QFileOpenEvent *fileOpenEvent = new QFileOpenEvent(filePath);
>>
>>    QCoreApplication::postEvent(QCoreApplication::instance(),
>> fileOpenEvent);
>>
>>
>>
>>    return YES;
>>
>> }
>>
>>
>>
>> @end
>>
>>
>>
>>
>> On Nov 13, 2015, at 12:24 PM, maitai <maitai at virtual-winds.org> wrote:
>>
>> Hello all,
>>
>> Since I updated to 5.5, I cannot launch my application by opening an email
>> attachment or such methods, for file extensions that have been registered
>> for my app in info.plist
>>
>> I can open the documents only if the app is already running.
>>
>> I can see in the app's log the following message:
>>
>> (...)
>> Nov 13 19:03:39 iPad-maitai com.apple.mdt[483] <Notice>: Copy
>> /var/mobile/Library/Mail/IMAP-xxxxxx at gmail.com@imap.gmail.com/INBOX.imapmbox/Attachments/2126/2/530_1.KAP
>> ->
>> /private/var/mobile/Containers/Data/Application/53F9684F-8FF2-4A10-A9BD-87A93C97FB11/Documents/Inbox
>> Nov 13 19:03:39 iPad-maitai kernel[0] <Notice>: xpcproxy[484] Container:
>> /private/var/mobile/Containers/Data/Application/53F9684F-8FF2-4A10-A9BD-87A93C97FB11
>> (sandbox)
>> Nov 13 19:03:39 iPad-maitai qtVlm[484] <Warning>:
>> didFinishLaunchingWithOptions option happen
>> Nov 13 19:03:39 iPad-maitai qtVlm[484] <Warning>: url received:
>> /private/var/mobile/Containers/Data/Application/53F9684F-8FF2-4A10-A9BD-87A93C97FB11/Documents/Inbox/530_1.KAP
>> Nov 13 19:03:40 iPad-maitai kernel[0] <Notice>: Sandbox: qtVlm(484) deny(1)
>> file-read-data /dev/tty
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: qwarning received:
>> starting up nslogmessage
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: qwarning received: step 2
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: qwarning received: step 3
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: qwarning received: step 4
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: <CATransformLayer:
>> 0x15da1ee0> - changing property masksToBounds in transform-only layer, will
>> have no effect
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: <CATransformLayer:
>> 0x15da4680> - changing property masksToBounds in transform-only layer, will
>> have no effect
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: <CATransformLayer:
>> 0x15d50730> - changing property masksToBounds in transform-only layer, will
>> have no effect
>> Nov 13 19:03:40 iPad-maitai qtVlm[484] <Warning>: qwarning received: step 5
>> just before qApp->exec()
>> Nov 13 19:03:41 iPad-maitai kernel[0] <Notice>: 024305.657672 wlan0.W[123]
>> AWDL MODE: OFF
>> Nov 13 19:03:57 iPad-maitai backboardd[63] <Warning>: CoreAnimation: updates
>> deferred for too long
>> Nov 13 19:03:59 iPad-maitai SpringBoard[48] <Warning>: Forcing crash report
>> of <FBApplicationProcess: 0x192412a0; qtVlm; pid: 484> (reason: 1,
>> description: com.meltemus.qtvlm failed to scene-create after 19.68s (launch
>> took 0.32s of total time limit 20.00s))
>> (...)
>>
>> The full story is that I override QIOSApplicationDelegate to be able to
>> manage didFinishLaunchingWithOptions and openUrl methods, but even if I
>> remove my implementations and let Qt regular QIOSApplicationDelegate load, I
>> get the same crash. I can see that main.cpp reaches the point where it calls
>> qApp->exec() and stays stuck there until a timeout of some sort occurs. I
>> can see that didFinishLaunchingWithOptions is called if I activate my own
>> delegate, as you can read from the log. But anyway with or without my own
>> delegate, I get this crash when I launch the app through a file opening.
>> What is this message about CoreAnimation taking too long that I don't get
>> when I launch the app normally?
>>
>> If I launch the application by clicking on the icon, it works and takes less
>> than 2secs to load, and it will even accept all incoming files through
>> openUrl. didFinishLaunchingWithOptions is called at startup too, but with no
>> url as expected.
>>
>> I am sure that was working before with qt 5.4.2.
>>
>> What should I do to make this working? And btw what is the recommended way
>> to override QIOSApplicationDelegate in order not to be annoyed each time a
>> new qt version is released, and still be able to handle openUrl and such?
>>
>> Thanks in advance
>> Philippe Lelong
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>> This email and any files transmitted with it from The Charles Machine Works,
>> Inc. are confidential and intended solely for the use of the individual or
>> entity to which they are addressed. If you have received this email in error
>> please notify the sender. Our company accepts no liability for the contents
>> of this email, or for the consequences of any actions taken on the basis of
>> the information provided, unless that information is subsequently confirmed
>> in writing. Please note that any views or opinions presented in this email
>> are solely those of the author and do not necessarily represent those of the
>> company. Finally, the recipient should check this email and any attachments
>> for the presence of viruses. The company accepts no liability for any damage
>> caused by any virus transmitted by this email.
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>> This email and any files transmitted with it from The Charles Machine Works,
>> Inc. are confidential and intended solely for the use of the individual or
>> entity to which they are addressed. If you have received this email in error
>> please notify the sender. Our company accepts no liability for the contents
>> of this email, or for the consequences of any actions taken on the basis of
>> the information provided, unless that information is subsequently confirmed
>> in writing. Please note that any views or opinions presented in this email
>> are solely those of the author and do not necessarily represent those of the
>> company. Finally, the recipient should check this email and any attachments
>> for the presence of viruses. The company accepts no liability for any damage
>> caused by any virus transmitted by this email.
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>> This email and any files transmitted with it from The Charles Machine Works,
>> Inc. are confidential and intended solely for the use of the individual or
>> entity to which they are addressed. If you have received this email in error
>> please notify the sender. Our company accepts no liability for the contents
>> of this email, or for the consequences of any actions taken on the basis of
>> the information provided, unless that information is subsequently confirmed
>> in writing. Please note that any views or opinions presented in this email
>> are solely those of the author and do not necessarily represent those of the
>> company. Finally, the recipient should check this email and any attachments
>> for the presence of viruses. The company accepts no liability for any damage
>> caused by any virus transmitted by this email.
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

This email and any files transmitted with it from The Charles Machine Works, Inc. are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify the sender. Our company accepts no liability for the contents of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.


More information about the Interest mailing list