Back To {AppName} Not Showing Up | iOS9 openURL
Asked Answered
U

3

6

I'm using the following code:

NSString *customURLString = [NSString stringWithFormat: @"secondApp://?%@", [document fileId]];
NSURL *customURL = [NSURL URLWithString: customURLString];
[[UIApplication sharedApplication] openURL: customURL];

The "Back To firstApp" is not showing up upon successful opening of the secondApp. Is there something I'm missing? Been scouring the internet for this answer, and am trying to make sure that "Back To firstApp" is there.

Has anyone come across this?

Unoccupied answered 14/1, 2016 at 17:9 Comment(0)
U
2

I found out the answer.

Apparently, if you put this in your info.plist for the second app, enter image description here

and declare that View controller-based status bar appearance is NO. It will not show the back to button. Not quite sure why, but this resolved my issue.

Thank you everyone for the support!

Unoccupied answered 21/1, 2016 at 15:44 Comment(1)
Looks like I am currently experiencing this same issue but exclusive to iPad devices. Ever find a good explanation or do you assume this is an OS bug? I can fix it exactly as you described.Furtive
P
1

Worth checking: "Back to ..." appear only when statusBar is visible. Are you sure your second app show statusBar?

The only explanation that came to my mind is that your second app can use depracated fullscreen launch method. Please check if:

Your code is fine, please check if this gave you this desired behaviour.

[[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"https://stackoverflow.com"]];

If so, there is a problem with your second app.

Psephology answered 19/1, 2016 at 15:42 Comment(2)
Where would I go to check this? It is showing the status bar, but where do I go to check the full screen launch method?Unoccupied
Nevermind, found it. I'm not using the full screen launch and it is visible at launch.Unoccupied
P
1

Set your Destination application's info.plist like this.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>Myapp</string>
</array>
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.Myapp.demo</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>Myapp</string>
        </array>
    </dict>
</array>

Put this method in your destination app's AppDelegate.m

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

Now from you source application open destination app using this.

NSString *customURLString = [NSString stringWithFormat: @"Myapp://"];
NSURL *customURL = [NSURL URLWithString: customURLString];

[[UIApplication sharedApplication] openURL: customURL];

This will surely show Back To App on status bar.

You can also check by typing Myapp:// from Safari. it will open your app with Back To Safari.

Peterson answered 21/1, 2016 at 13:51 Comment(3)
This is exactly what I have, and it's not working >_<Unoccupied
But, its working in my application. May be you are missing something.Peterson
Yes, I just tried it from Safari, and it's not saying back to safari either.Unoccupied

© 2022 - 2024 — McMap. All rights reserved.