Spotify SPTAuth canHandleURL is crashing with NSInvalidArgumentException

386 views Asked by At

I have upgraded Spotify from Beta6 to Beta9. One of the necessary changes to support the upgrade is to the canHandleURL method signature. The Beta6 signature was:

canHandleURL: withDeclaredRedirectURL:

The new signature removes withDeclaredRedirectURL. However, when I try to execute the method with the new signature from my appDelegate in the following manner:

-(BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
   sourceApplication:(NSString *)sourceApplication
           annotation:(id)annotation {

    if ([[SPTAuth defaultInstance] canHandleURL:url]) {

        [[SPTAuth defaultInstance]
         handleAuthCallbackWithTriggeredAuthURL:url callback:^(NSError *error, SPTSession *session) {

             if (error != nil) {
                 ...
                 return;
             }

             // Save the session info
             ...
         }];
        return YES;
    }
    ...
    return NO;
}

The error is as follows:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFString hasPrefix:]: nil argument'
*** First throw call stack:
(
 0   CoreFoundation                      0x0000000112eeec65 __exceptionPreprocess + 165
 1   libobjc.A.dylib                     0x0000000112b87bb7 objc_exception_throw + 45
 2   CoreFoundation                      0x0000000112eeeb9d +[NSException raise:format:] + 205
3   CoreFoundation                      0x0000000112e0ee00 -[__NSCFString hasPrefix:] + 96
4   MyAPP                        0x000000010fa64c0a -[SPTAuth _canHandleURL:withDeclaredRedirectURL:] + 143
5   MyAPP                        0x000000010fa64c7e -[SPTAuth canHandleURL:] + 82
6   MyAPP                        0x000000010f9e8c09 -[myAppDelegate application:openURL:sourceApplication:annotation:] + 73
7   UIKit                               0x0000000111159cd0 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 144
8   UIKit                               0x0000000111159c31 -[UIApplication _applicationOpenURL:payload:] + 333
9   UIKit                               0x0000000111162328 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:] + 2350
10  UIKit                               0x0000000111165e71 __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 196
11  UIKit                               0x0000000111165d9e -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 349
12  UIKit                               0x00000001111507fa -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 486
 13  FrontBoardServices                  0x00000001175605e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
 14  CoreFoundation                      0x0000000112e2241c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
 15  CoreFoundation                      0x0000000112e18165 __CFRunLoopDoBlocks + 341
16  CoreFoundation                      0x0000000112e17f25 __CFRunLoopRun + 2389
17  CoreFoundation                      0x0000000112e17366 CFRunLoopRunSpecific + 470
18  GraphicsServices                    0x00000001138f6a3e GSEventRunModal + 161
19  UIKit                               0x0000000111152900 UIApplicationMain + 1282
20  MyAPP                        0x000000010f9925b1 main + 97
21  libdyld.dylib                       0x0000000113420145 start + 1
22  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

This code appears to follow the iOS SDK tutorial, so I am not sure why this is crashing. When I updated the Spotify.framework, I deleted the old one (moved to trash) and I deleted the Derived Data to clear out the cache in the compiler. Then I dragged the new Spotify.framework into Xcode. Can you see if I have made some mistake? Please help.

0

There are 0 answers