Reputation: 526
In my today-extension I use the following code to launch my app:
NSURL *url = [NSURL URLWithString:@"hdb://"];
[[self extensionContext] openURL:url completionHandler:nil];
Is it possible to call a specific ViewController to be displayed after launching the app? In my app all ViewControllers are called with their segues like:
[self.mainSlideMenu.leftMenu performSegueWithIdentifier:@"NewsPhoneSegue" sender:self];
Upvotes: 1
Views: 1444
Reputation: 526
I solved it by writing in the today-extension a Int in the UserDefaults which I get now from my downloaded xml-file and in my first VC of the app I check the value by "case". So case 0 the app launches as required by the settings, case 1 the app launches with the News, case 2 with other view and so on. In each case I added to reset the Int to 0 otherwise when launching the app by the icon my settings are ignored because the value is stored from the last time the extension was used.
The code in the today-extension before the openURL is called:
NSString *ZwischenZiel = [[self.todayParser.todayArray objectAtIndex:indexPath.row] View];
NSInteger Ziel = [ZwischenZiel integerValue];
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.company.HdB"];
[sharedDefaults setInteger:Ziel forKey:@"ViewValue"];
[sharedDefaults synchronize];
and in the first viewController in the app:
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.company.HdB"];
NSInteger Wert = [sharedDefaults integerForKey:@"ViewValue"];
switch (Wert) {
case 0:
//if-else for passing the right segue respecting settings
if ([manualStartSeite isEqual:@"lalala"]) {
[self.mainSlideMenu.leftMenu performSegueWithIdentifier:@"lalalaPhoneSegue" sender:self];
} else {
}
break;
case 1:
//News
[self.mainSlideMenu.leftMenu performSegueWithIdentifier:@"NewsPhoneSegue" sender:self];
[sharedDefaults setInteger:0 forKey:@"ViewValue"];
[sharedDefaults synchronize];
break;
case 2:
Upvotes: 1
Reputation: 660
If I did understand what you are asking, you can create a view controller at the very begging of your app and in its viewwillappear you can call perform segue with identifier method to call your specific view controller. Hope it helps.
Upvotes: 0