是否可以在Objective C中打开正在运行的后台应用程序
问题描述:
在特定时间从后台打开我的应用.
open my app from background running on a specific timing..
想做这样的事
- (void)applicationDidEnterBackground:(UIApplication *)application
{
timer = [NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(timerFired:)
userInfo:nil
repeats:NO];
}
- (void)timerFired:(NSTimer*)timer
{
NSLog( @"yes it is running...");
PickUpCallViewController *call=[[PickUpCallViewController alloc]initWithNibName:@"PickUpCallViewController" bundle:nil];
navi=[[UINavigationController alloc]initWithRootViewController:call];
[[navi navigationController] setNavigationBarHidden:YES animated:YES];
window.rootViewController = navi;
[window makeKeyAndVisible];
}
答
在后台模式下进行应用时,无法以编程方式打开应用.但是,使用URL方案,您可以从浏览器打开应用.
It is not possible to open programmatically app when you application in to background Mode. But using URL-scheme you can open App from browser.
您只需要按照以下屏幕截图设置URL方案:-
You just need to set URL scheme as following screenshot:-
- 首先,您需要打开项目-> Target->信息
- 单击此信息后,您在Bottom处发现了以下屏幕截图:
- 单击"URL类型",您将得到如下屏幕截图所示的结果:
- 单击(+)并按如下所示设置URL方案:
- click on (+) and setting URL-Schemes as following:
通过点击主页"按钮保存并最小化您的应用程序,然后打开您的野生动物园浏览器.然后只需输入您要设置的 mytestApp://,然后保存为以下屏幕截图即可:-
Save and minimized your application by tapping Home button and open your safari browser. and just type mytestApp:// that you are setting before save as following screenshot:-
所有过程均正常运行,例如:-
That all process working fine like:-