Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

iOS File Association in Xamarin Forms application?

$
0
0

Hello guys,
hopeyfully this is the correct forum for my request.

I am working on a Xamarin Forms application. Now I want to implement File Association for the iOS App for PDF and png files.
Therefore I added this to the plist file.

<key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeName</key>
                <string>PDF</string>
                <key>LSHandlerRank</key>
                <string>Alternate</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string>com.adobe.pdf</string>
                </array>
            </dict>
            <dict>
                <key>CFBundleTypeName</key>
                <string>PNG</string>
                <key>LSHandlerRank</key>
                <string>Alternate</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string>public.png</string>
                </array>
            </dict>
        </array>

In the appdelegate I catch the file like this:
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
 {       
     Console.WriteLine("Invoked with OpenUrl: {0}", url.AbsoluteString);
     return true;
 }

Based on this I wan't the app to navigate to a page were I am willing to use the file.

Now I ran into a problem. When I import a file to the app nothing happens and I get the following error in the devicelog:

Sep 14 11:42:09 stefans-imac2.andagon.local com.apple.mdt[6159]: Copy /Users/pasqueju/Library/Developer/CoreSimulator/Devices/8AEFCE3E-EEA8-475F-9E3F-174B8E9AD8EB/data/Containers/Data/Application/E354FC7C-744E-41E6-9B13-9A66BE0E7AEC/tmp/QuickLookPDF-peBjnPAz/entgeltbeleg_muster.pdf -> /Users/pasqueju/Library/Developer/CoreSimulator/Devices/8AEFCE3E-EEA8-475F-9E3F-174B8E9AD8EB/data/Containers/Data/Application/01A2661A-FFEE-4A6D-AF49-559484162433/Documents/Inbox
Sep 14 11:42:09 stefans-imac2 assertiond[4323]: assertion failed: 14F27 12F69: assertiond + 12334 [8E465C14-E4AE-36E9-AFBE-D28459602962]: 0x1
Sep 14 11:42:09 --- last message repeated 6 times ---
Sep 14 11:42:09 stefans-imac2.andagon.local AndagonAppiOS[6150]: Invoked with OpenUrl: file:///Users/pasqueju/Library/Developer/CoreSimulator/Devices/8AEFCE3E-EEA8-475F-9E3F-174B8E9AD8EB/data/Containers/Data/Application/01A2661A-FFEE-4A6D-AF49-559484162433/Documents/Inbox/entgeltbeleg_muster.pdf
Sep 14 11:42:09 stefans-imac2.andagon.local SpringBoard[4319]: [MPUSystemMediaControls] Updating supported commands for now playing application.
Sep 14 11:42:09 stefans-imac2.andagon.local splashboardd[6160]: *** Assertion failure in -[UINib initWithNibName:directory:bundle:], /SourceCache/UIKit_Sim/UIKit-3347.44/UINib.m:98
Sep 14 11:42:09 stefans-imac2.andagon.local splashboardd[6160]: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x000000010405dc65 __exceptionPreprocess + 165
        1   libobjc.A.dylib                     0x0000000103cbabb7 objc_exception_throw + 45
        2   CoreFoundation                      0x000000010405daca +[NSException raise:format:arguments:] + 106
        3   Foundation                          0x000000010382698f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
        4   UIKit                               0x00000001027762a0 -[UINib initWithNibName:directory:bundle:] + 164
        5   UIKit                               0x000000010277639d +[UINib nibWithNibName:bundle:] + 61
        6   splashboardd                        0x0000000101d29847 splashboardd + 6215
        7   libdispatch.dylib                   0x0000000104973964 _dispatch_client_callout + 8
        8   libdispatch.dylib                   0x0000000104960818 _dispatch_barrier_sync_f_slow_invoke + 51
        9   libdispatch.dylib                   0x0000000104973964 _dispatch_client_callout + 8
        10  libdispatch.dylib                   0x000000010495ea59 _dispatch_main_queue_callback_4CF + 704
        11  CoreFoundation                      0x0000000103fc51f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
        12  CoreFoundation                      0x0000000103f86dcb __CFRunLoopRun + 2043
        13  CoreFoundation                      0x0000000103f86366 CFRunLoopRunSpecific + 470
        14  Foundation                          0x00000001037c7f92 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 275
        15  Foundation                          0x0000000103853080 -[NSRunLoop(NSRunLoop) run] + 74
        16  splashboardd                        0x0000000101d29d0c splashboardd + 7436
        17  libdyld.dylib                       0x00000001049a3145 start + 1
    )
Sep 14 11:42:09 stefans-imac2.andagon.local SpringBoard[4319]: BSXPCMessage received error for message: Connection interrupted
Sep 14 11:42:09 stefans-imac2 com.apple.CoreSimulator.SimDevice.8AEFCE3E-EEA8-475F-9E3F-174B8E9AD8EB.launchd_sim[4305] (com.apple.splashboard.9411E059-C0CD-4AE5-9034-F1D350BC274C[6160]): Service exited due to signal: Abort trap: 6
Sep 14 11:42:09 stefans-imac2 assertiond[4323]: assertion failed: 14F27 12F69: assertiond + 12334 [8E465C14-E4AE-36E9-AFBE-D28459602962]: 0x1
Sep 14 11:42:39 --- last message repeated 7 times ---

Irrespective of this error I was wondering how to navigate away from the appdelegate anyways.
Did anyone of you already implement file association and solved these problems?

Best regards
Julian


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>