Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where apps cannot be launched on iOS 18 #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 30 additions & 22 deletions ios/Classes/LaunchexternalappPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,48 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {

if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
} else
if ([@"isAppInstalled" isEqualToString:call.method]) {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:call.arguments[@"package_name"]]]){
} else if ([@"isAppInstalled" isEqualToString:call.method]) {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:call.arguments[@"package_name"]]]) {
result(@(YES));
} else{
result(@(NO));}
} else {
result(@(NO));
}

} else if ([@"openApp" isEqualToString:call.method]) {
@try {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:call.arguments[@"package_name"]]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:call.arguments[@"package_name"]]];
result(@("app_opened"));
} else
{
@try {
NSURL *url = [NSURL URLWithString:call.arguments[@"package_name"]];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (success) {
result(@("app_opened"));
} else {
result(@("Failed to open app"));
}
}];
} else {
NSLog(@"Is reaching here1");
if(![@"false" isEqualToString: call.arguments[@"open_store"]]) {
NSLog(@"Is reaching here2 %@", call.arguments[@"app_store_link"]);

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:call.arguments[@"app_store_link"]]];
result(@("navigated_to_store"));

NSURL *storeUrl = [NSURL URLWithString:call.arguments[@"app_store_link"]];
[[UIApplication sharedApplication] openURL:storeUrl options:@{} completionHandler:^(BOOL success) {
if (success) {
result(@("navigated_to_store"));
} else {
result(@("Failed to navigate to store"));
}
}];
} else {
result(@("App not found on the device"));
}
result(@("App not found in the device"));
}
}
@catch (NSException * e) {
NSLog(@"exception herre");
result(e);

} @catch (NSException *e) {
NSLog(@"exception here");
result(e);
}
} else {
result(FlutterMethodNotImplemented);
}

}

@end