cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DB Chooser failing in iOS9 - app not allowed to query for scheme

DB Chooser failing in iOS9 - app not allowed to query for scheme

Steve M.52
New member | Level 1

I'm using DBChooser in my app. The Dropbox app is installed on the device and updated. I'm using iOS 9.3.5.

I have registered schemes dbapi-1, dbapi-2 and dbapip-3 in LSApplicationQueriesSchemes in <app>-Info.plist. I have also registered db-<my_app_key> under URL Types (obviously, with my actual app key). Aside from adding dbapi-2, this is all unchanged from the previous version of the app in which everything was working.

So, what happens now is that when I run the following code:

- (void)executeDropboxImport

{

  [[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypeDirect

fromViewController:self

completion:^(NSArray *results) {

    if ([results count]) {

    NSDictionary *jsonDict = nil;

    DBChooserResult *file = [results firstObject];

    NSString *ext = [file.name pathExtension].uppercaseString;

    NSString *importFile = [NSString stringWithFormat:@"ImportFile.%@", ext];

    NSString *localPath = [NSTemporaryDirectory() stringByAppendingPathComponent:importFile];

// Make a local copy of the file

    if (file.size > 0 && ([ext isEqualToString:@"JSNST"])) {

    NSData *localFileData = [NSData dataWithContentsOfURL:file.link];

    [localFileData writeToFile:localPath atomically:YES];

   // ... do stuff with the data ...

}];

}

Watching the device's console log, when this method is called I see:

Sep 17 09:03:10 Steves-iPhone5 Dropbox[1369] <Warning>: -canOpenURL: failed for URL: "dbx-carousel://" - error: "(null)"
Sep 17 09:03:10 Steves-iPhone5 Dropbox[1369] <Warning>: -canOpenURL: failed for URL: "dbx-mailbox://" - error: "(null)"
Sep 17 09:03:11 Steves-iPhone5 Dropbox[1369] <Warning>: -canOpenURL: failed for URL: "dbx-carousel://" - error: "(null)"
Sep 17 09:03:11 Steves-iPhone5 Dropbox[1369] <Warning>: -canOpenURL: failed for URL: "dbx-carousel://" - error: "(null)"

Shortly followed by:


Sep 17 09:04:14 Steves-iPhone5 Dropbox[1369] <Warning>: -canOpenURL: failed for URL: "db-<my_app_key>://1/chooser?files=%5B%7B%22link%22%3A%22https%3A%2F%2Fdl.dropboxusercontent.com%2F1%2Fview%2Fcbm3aag0sip8eiz%2FStoryFlow%2520Docs%2FStoryFlow_ShotTypes.jsnst%22%2C%22bytes%22%3A1079%2C%22name%22%3A%22StoryFlow_ShotTypes.jsnst%22%2C%22is_dir%22%3Afalse%2C%22icon%22%3A%22https%3A%2F%2Fwww.dropbox.com%2Fstatic%2Fimages%2Ficons64%2Fpage_white.png%22%2C%22isDir%22%3Afalse%2C%22thumbnails%22%3A%7B%7D%7D%5D" - error: "This app is not allowed to query for scheme db-<my_app_key>"

 

It's finding the file okay. But why is it 'not allowed to query' when I have that scheme registered?

What happens is that the import just fails silently. Like I say, the file is seen but nothing is done with it.
...

16 Replies 16

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Steve M.52
New member | Level 1

BTW, DBChooser has been working fine with all previous versions of the app, using the same DB app key that was created a couple of years ago. I'm pretty sure it was working, too, with this version of the app when I first created it some months ago. The problem seems to have crept in when I recompiled the app after updating to Xcode 7.

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Greg-DB
Dropboxer

[Cross-linking for reference: https://stackoverflow.com/questions/39544755/dropbox-chooser-failing-in-ios9-app-not-allowed-to-quer... ]

Apple did introduce some restrictions around these URL calls in iOS 9. The plist registrations you mentioned should cover everything though.

The 'error: "(null)"' messages can be ignored. Those are essentially just noise, as there are no actual errors being reported.

The 'This app is not allowed to query for scheme' error looks real though. To start looking into that, can you share the actual snippets from your plist file with the URL scheme registrations? 

Also, just to be clear, does it fail in that "openURL" in your app is never called, so it can never import the file?

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Steve M.52
New member | Level 1

Here's what I have in the .plist file. As you can see, I even tried adding the db-<my_app_key> to LSApplicationQueriesSchemes. Doesn't work with or without that.

<key>CFBundleURLTypes</key>

<array>

  <dict>

    <key>CFBundleTypeRole</key>

    <string>Editor</string>

    <key>CFBundleURLSchemes</key>

    <array>

      <string>db-my_app_key</string>

    </array>

  </dict>

</array>

<key>LSApplicationQueriesSchemes</key>

<array>

  <string>dbapi-1</string>

  <string>dbapi-2</string>

  <string>dbapi-3</string>

  <string>db-my_app_key</string>

</array>

 

I tried adding some NSLog messages to the code. As you can see, all the work is being done within the closure. But none of the NSLog messages in that section of text are showing up, so it's like the closure code isn't being executed.

One other thing: sometimes I'm also getting network errors (see below). I don't get these every time, and even when I don't the import process is still failing. Having googled this somewhat, I'm under the impression that this error is to do with fallback to cellular if wifi is weak. (Don't know why it's doing this because the wifi signal is strong and everything else - eg, mail, browser - are working fine). Also, this problem with the import isn't just with me - I have a user reporting the same issue. But for the sake of completeness, here's the other error I'm seeing:

 

Sep 20 08:49:45 Steves-iPhone5 networkd[1251] <Error>: -[NETAWDManager reportStats:metricID:] AWDServerConnection newMetricContainerWithIdentifier failed for metric 2686983, server 0x16e5a9c0, not reporting:
<AWDLibnetcoreTCPConnectionReport: 0x16e8edd0> {
cellularFallbackReport = {
dataUsageSnapshotsAtNetworkEvents = (
{
bytesIn = 5100;
bytesOut = 1000;
},
{
bytesIn = 5500;
bytesOut = 1600;
}
);
"fallbackTimer_msecs" = 0;
fellback = 0;
networkEvents = (
"NETWORK_EVENT_DATA_STALL_AT_APP_LAYER",
"NETWORK_EVENT_DATA_STALL_AT_APP_LAYER"
);
"timeToNetworkEvents_msecs" = (
4240,
40473
);
};
clientIdentifier = "com.getdropbox.Dropbox";
connectionStatisticsReport = {
DNSAnswersCached = 0;
"DNSResolvedTime_msecs" = 58;
RTTvariance = 0;
"appDataStallTimer_msecs" = 3;
appReportingDataStallCount = 2;
"bestRTT_msecs" = 0;
betterRouteEventCount = 0;
bytesDuplicate = 0;
bytesIn = 0;
bytesOut = 0;
bytesOutOfOrder = 0;
bytesRetransmitted = 0;
cellularFallback = 0;
cellularRRCConnected = 0;
connected = 1;
connectedInterfaceType = "INTERFACE_TYPE_WIFI";
"connectionEstablishmentTime_msecs" = 253;
connectionReuseCount = 0;
"currentRTT_msecs" = 0;
"flowDuration_msecs" = 37379869;
interfaceType = "INTERFACE_TYPE_WIFI";
kernelReportedStalls = 0;
kernelReportingConnectionStalled = 0;
kernelReportingReadStalled = 0;
kernelReportingWriteStalled = 0;
packetsDuplicate = 0;
packetsIn = 0;
packetsOut = 0;
packetsOutOfOrder = 0;
packetsRetransmitted = 0;
"smoothedRTT_msecs" = 0;
synRetransmissionCount = 0;
tcpFastOpen = 0;
"timeToConnectionEstablishment_msecs" = 316;
"timeToConnectionStart_msecs" = 63;
"timeToDNSResolved_msecs" = 60;
"timeToDNSStart_msecs" = 2;
trafficClass = 0;
};
delegated = 0;
reportReason = "REPORT_REASON_DATA_STALL_AT_APP_LAYER";
}

 

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Steve M.52
New member | Level 1

I also tried it a slightly different way:

 

- (void)executeDropboxImport

{

  NSLog(@">>>>> Creating chooser <<<<<");

  DBChooser *chooser = [[DBChooser defaultChooser] initWithAppKey:@"db-my_app_key"];

  NSLog(@">>>>> opening chooser <<<<<");

  [chooser openChooserForLinkType:DBChooserLinkTypeDirect fromViewController:self completion:^(NSArray *results) {

    // closure code

  }];

}

With this approach I see both of those NSLog messages, but the import fails and on the device I get the alert dialogue saying:

Unable to Generate Link

Sorry, an error occurred. Please try again later.

Nothing appears in the console (the 'not allowed to query' error doesn't appear), including the NSLog messages. In fact, I'm left in the DBChooser with no direct way to get back to my app. Of course, that may be because I'm doing it wrong. 😉

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Greg-DB
Dropboxer

Thanks Steve! (For reference, I believe all of the new networkd logging output is new with the latest Xcode, and is unrelated to the issue at hand.)

Also, you don't need to add your own db-appkey to LSApplicationQueriesSchemes, but it shouldn't make a difference either way.

Anyway, when using the initWithAppKey version, the app key you pass as the parameter to initWithAppKey should be just the app key itself, without the db- prefix. That's causing the new "Unable to Generate Link" issue. (You also usually won't need to use initWithAppKey anyway.)

And as far as the original issue is concerned, I'm trying to reproduce it, but haven't been able to yet. Some other potentially useful pieces of information:

- Does the Chooser sample app work for you? 

- What version of the official Dropbox for iOS app do you have installed?

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Steve M.52
New member | Level 1

The Dropbox for iOS app is 16.2.4.

As for the sample app - well that's a problem. It failed to build with a linker error, reporting:

'/Users/steve/Dev-Apple/dropbox-ios-dropins-sdk-1.2.1/DBChooser.framework/DBChooser(DBChooser.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7

I tried disabling bitcode. The example app then builds, but when run on the device thinks that the Dropbox app isn't installed and prompts me to install it. I opened DBChooser.xcodeproj and that seems to be set to use bitcode. I tried rebuilding that but it didn't seem to help.

FYI, my app was set NOT to use bitcode. I tried changing that but got the same linker error as for the example app.

 

 

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Greg-DB
Dropboxer

Apologies, the example app is a bit outdated now. I should have mentioned that you'll need to make a few adjustments to compatible with the latest versions of iOS. You already figured out how to work around the bitcode issue, and to allow it to "see" the Dropbox app you will need to add the LSApplicationQueriesSchemes entries to the example's plist file (as shown here).

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Steve M.52
New member | Level 1

Damn, should've thought about the LSApplicationQueriesSchemes. Now the example app is working fine...

 

Re: DB Chooser failing in iOS9 - app not allowed to query for scheme

Greg-DB
Dropboxer

Thanks! It sounds like the issue may come down to how you're calling or receiving the Chooser in your app specifically then. That being the case, can you share your code, both the calling code and the receiving code in openURL? Also, please don't redact your app key since that may be relevant. (App keys aren't considered secret, but feel free share it via your API ticket if you'd prefer.)

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Steve M.52 New member | Level 1
What do Dropbox user levels mean?
Need more support?