gpt4 book ai didi

iOs 从保存状态打开应用

转载 作者:行者123 更新时间:2023-11-29 03:05:20 25 4
gpt4 key购买 nike

我的应用程序有 2 个主要功能:

  1. 预约功能
  2. 消息传递功能

在启动过程中,应用程序下载数据的初始部分(将日历与服务器同步,从服务器获取新消息)。我在该过程中使用启动屏幕。

当应用程序进入保存状态时,用户可以使用聊天中的推送消息打开应用程序。

我已经覆盖了

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[SKPaymentQueue defaultQueue] addTransactionObserver:[PurchaseHelper sharedInstance]];

[Parse setApplicationId:kPLParseAppId clientKey:kPLParseClientId];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];

[Crashlytics startWithAPIKey:@"mykey"];

// social networks API
[PFFacebookUtils initializeFacebook];
[[OkClient sharedInstance] initializeOdnoklassniki];
[[VkClient sharedInstance] initializeVk];

// load magical record support
[MagicalRecord setupCoreDataStackWithStoreNamed:@"Model.sqlite"];

// subscribe to notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidLogin) name:kPLUserDidLoginNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidLogout) name:kPLUserDidLogoutNotification object:nil];

// subscribe to pushes
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];

UIColor *greenColor = [UIColor colorWithRed:111 green:221 blue:215 andAlpha:255];
if([[UINavigationBar appearance] respondsToSelector:@selector(barTintColor)]) {
// iOS7
[UINavigationBar appearance].barTintColor = greenColor;
} else {
// older
[UINavigationBar appearance].tintColor = greenColor;
}

[[UINavigationBar appearance] setTitleTextAttributes:
@{NSFontAttributeName : [UIFont fontWithName:@"Circe-Regular" size:16.],
NSForegroundColorAttributeName: [UIColor blackColor]}];


[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Circe-Regular" size:16.], NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];

// if app is started from push open chat
if (launchOptions != nil) {
NSDictionary *dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (dictionary != nil) {
ChatModel *chat = [self handlePushNotification:dictionary];
[self launchChat:chat];
}
}

// update purchase data if user is authenticated
if ([[UserApiClient sharedInstance] isAuthenticated]) {
[self updatePurchaseData];
}

// add styles
[self addStyle];


return YES;
}

launchChat 是:

- (void) launchChat:(ChatModel *) chat {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// reveal controller
UIViewController *revealController = [storyboard instantiateViewControllerWithIdentifier:@"AuxController"];

ChatViewController *chatController = [storyboard instantiateViewControllerWithIdentifier:@"chatVC"];
chatController.chatModelId = chat.objectID;


self.window.rootViewController = revealController;

for (UIViewController *controller in [revealController childViewControllers]){
if ([controller isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController *) controller;
[navController pushViewController:chatController animated:YES];
break;
}
}
}

但不幸的是,我得到了常规的启动画面,而不是 ChatViewController。我的错误在哪里?

最佳答案

我想您需要替换 window 而不仅仅是 rootViewController。我不能说我实际上已经用 Storyboard做到了,所以这有点猜测......

如果它不起作用,您需要删除 Storyboard 中的初始 View Controller 指定并在所有情况下在代码中配置 rootViewController

关于iOs 从保存状态打开应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22836479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com