I am trying to launch my app with a custom URL scheme. If the app is backgrounded, all is fine. If the app is not backgrounded, it launches, and the launch screen never disappears, eventually it gets killed by iOS for taking too long. I have extensively debugged this, and cannot figure out the problem. I have even removed everything from my application didFinishLauinchingWithOptions to make sure that nothing was stopping it there. This is my altered code, all I am asking is that it opens and gives me a blank window, but won't even do that. Just hangs on launch screen.
if ([launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]) {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
self.window.rootViewController = [[UIViewController alloc]init];
return YES;
}
URL Scheme in plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb23423444322</string>
<string>test</string>
</array>
</dict>
</array>
</plist>
How are you handling what happens when your application responds to the URL Scheme. You should be use this delegate method in your App Delegate:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// Do what you need here
return YES;
}
Check the contents of didFinishLaunchingWithOptions. The code in this method should not be commented out. Also it looks like you have a conditional in the didFinishLaunchingWithOptions method. This is most likely while the app is hanging on startup.
Related
I am trying to open my native iPhone application from a link in safari. I have followed this link to create a url schema. I have added appgo:// as my url schema and com.xxxx.appgo as Identifier under URL Types. Following is my link in web page in safari: Open iPhone App
But when I click on the link the app doesn't open up and safari produce an alert with error: Safari cannot enter the page as the address is invalid.
my bundle identifier: com.xxxxx.abc
Note: My bundle identifier is different from the identifier in URL types. Can that be an issue?
Edit:
I have made bundle identifier and url identifier same. I have also added following code in my app delegate:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
NSLog(#"application");
BOOL returnValue = NO;
NSString *urlString = [url absoluteString];
if([urlString hasPrefix:#"com.xxxx.appgo"]){
returnValue = YES;
}
return returnValue;
}
I am testing it in my iPad. I first install the latest version of app from xcode and then press on home button and then open the link in safari. But I am still getting the alert saying the Safari cannot enter the page as address is invalid. My link in safari:
Open iPhone App
Implement in app delegate
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
BOOL returnValue = NO;
NSString *urlString = [url absoluteString];
if([urlString hasPrefix:#"appgo://"]){
returnValue = YES;
}
return returnValue;
}
Edit:
Add in your info.plist file
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.xxxx.appgo</string>
<key>CFBundleURLSchemes</key>
<array>
<string>appgo</string>
<string>yourSecondScheme</string>
</array>
</dict>
</array>
Yes. Your bundle identifier must be same as the URL types in the plis file.
For more you can refer to this link.
I need to send file from one application to another. I use UIDocumentInteractionController to copy file.
Here is my code implementing UIDocumentInterationController in my ViewController in SendingApp.
NSString *path = [[NSBundle mainBundle] pathForResource:#"1" ofType:#"zip"];
NSURL *urlPath = [NSURL fileURLWithPath:path];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:urlPath];
[docController retain];
docController.delegate = self;
[docController presentOpenInMenuFromRect:self.view.frame
inView:self.view
animated:YES];
docController is property. ViewController implements UIDocumentInteractionControllerDelegate.
The ReceiverApp is set to handle the files of this extension.
My ReceiverAppInfo.plist
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>zip</string>
</array>
<key>CFBundleTypeName</key>
<string>ZIP</string>
<key>LSItemContentTypes</key>
<array>
<string>public.zip-archive</string>
<string>com.pkware.zip-archive</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
</dict>
</array>
In ReceiverAppDelegate I use
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
to handle opening of receiving file.
So problem is that this code works just perfect on iOS 5.1 BUT it doesn't work on iOS 6. UIDocumentInteractionController OpenIn menu appears and shows my ReceiverApp but it doesn't do anything if you select the app. I looked in Console and found out that iPhone Simulator 6.1 tries to copy file to one directory while Simulator 5.1 copies to another.
iPhoneSimulator 6.1
com.apple.mdt[2342]:
Copy ~/Library/Application Support/iPhone Simulator/6.1/Applications/367D395F-DC8B-4F4C-83C7-B22992E34C64/sendingZIP.app/1.zip ->
/var/mobile/Library/Application Support/Containers/-23.ReceiveApp/Documents/Inbox
iPhoneSimulator 5.1
com.apple.mdt[2439]:
Copy ~/Library/Application Support/iPhone Simulator/5.1/Applications/0DE1852A-F803-4583-87BC-8F1EBBE362A4/sendingZIP.app/1.zip ->
~/Library/Application Support/iPhone Simulator/5.1/Applications/927E310A-2766-4709-81CB-0E759F24236D/Documents/Inbox
Has anybody such problem? Does anybody know what to do?
Notice that the only discernible API difference is
Managing Actions
– documentInteractionController:canPerformAction: Deprecated in iOS 6.0
– documentInteractionController:performAction: Deprecated in iOS 6.0
Are you still implementing these methods? Maybe they are responsible for the unexpected results.
I'm just getting into iOS development, but something I'm going to have to do early on is add a button to the system menus like how Dropbox has added its button when interacting with email attachments.
This application will be for video so adding a button on the share menu for quicktime players would be ideal.
I've scoured the documentation and have only found the UIMenuItem class. Is this what I want or is there another way to implement this functionality?
Set project-info.plist -> add new item (UTExportedTypeDeclarations)
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>com.apple.quicktime-movie</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.company.project</string>
<key>UTTypeTagSpecification</key>
<dict/>
</dict>
</array>
Coding your ButtonClick event in .m file
-(IBAction)actionClick:(id)sender{
UIDocumentInteractionController *documentController =
[UIDocumentInteractionController interactionControllerWithURL:
[NSURL fileURLWithPath:MOVIE_FILE_PATH]];
documentController.delegate = self;
documentController.UTI = #"com.apple.quicktime-movie";
[documentController presentOpenInMenuFromRect:CGRectZero
inView:self.view
animated:YES];
}
I'm very new to using dropbox, and am looking for examples of syncing. I found CHDropboxSync and am in process of making the sample app included with the project work.
I'm running into the issue where dropbox "link with dropbox" webpage opens with prompt "ExampleApp wants access to a folder in your dropbox". The folder name appears correct. When I tap the green "Allow" button, the web browser closes and a black screen appears. A second later I see the iPhone's desktop. There are no error messages, but the app does not reopen after linking a dropbox account. What could be causing this issue? Has anyone else encountered such "crash to desktop" kind of issue with CHDropboxSync?
Here are the modifications that I made to the project to make it work:
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>db-CORRECT_APP_KEY</string>
</array>
</dict>
In the app delegate:
// Dropbox
#warning Put your app-folder-type dropbox keys in here
DBSession* dbSession = [[[DBSession alloc] initWithAppKey:#"CORRECT_KEY" appSecret:#"CORRECT_SECRET" root:kDBRootAppFolder] autorelease];
[DBSession setSharedSession:dbSession];
Thank you for any help!
I solved the problem by:
Creating a different dropbox app and updating the project with new key/secret/root folder
Implementing a different app delegate method:
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([[DBSession sharedSession] handleOpenURL:url]) {
if ([[DBSession sharedSession] isLinked]) {
NSLog(#"App linked successfully!");
[CHDropboxSync forgetStatus];
[[NSNotificationCenter defaultCenter] postNotificationName:#"Linked" object:nil];
// At this point you can start making API calls
}
return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}
I have a problem with custom URL schema. I think I've configured it properly but it doesn't open the app if it is closed, if the app is in "background" (i.e. I can see it double tapping the home button) the app is opened when I tap on the link.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.test</string>
<key>CFBundleURLSchemes</key>
<array>
<string>test</string>
<string>test1</string>
</array>
</dict>
</array>
the link is
TEST
other applications work fine but not mine.
Thanks,
Matteo
Do you return NO; anywhere in your - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation method?
I can't think of anything that would cause it to not open, aside from returning NO.