簡體   English   中英

從網址架構啟動應用程序時未調用didFinishLaunchingWithOptions

[英]didFinishLaunchingWithOptions not called when app launch from url schema

我是iOS開發的新手。 我想在我的應用程序上添加深層鏈接,因此我更喜歡使用URL架構,所以現在我想從另一個應用程序打開我的應用程序,然后該應用程序打開,並且立即崩潰,沒有任何一種方法被調用。

就像這里我在didFinishLaunchingWithOptions方法上添加了警報

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Info" message:@"Finish Called" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil,nil];
   [alert show];
   [self.window makeKeyAndVisible];
   return YES; 
}

而且當我的應用打開時不會調用此方法

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
 {
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Info" message:[NSString stringWithFormat:@"%@",url] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil,nil];
    [alert show];
    return YES;
 }

它只是打開了啟動畫面,崩潰了,有人可以幫我嗎?

先感謝您。

有2種情況
1.應用程序處於暫停狀態-當您單擊url時,將調用applicationdidFinishLaunchingWithOptions,並且您將在選項字典中獲取url,而openUrl方法將被跳過

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   return YES; 
}

2.如果app在后台,則僅調用openUrl方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM