Is it possible to open running background app on i

2019-05-23 22:54发布

open my app from background running on a specific timing..

want to do somthing like this

 - (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];
}

3条回答
倾城 Initia
2楼-- · 2019-05-23 23:29

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.

You just need to set URL scheme as following screenshot:-

  • First you need to open project-->Target-->info

enter image description here

  • After this click on info you found at Bottom like this screenshot:

enter image description here

  • Click on URL Type you got result like following screenshot:

enter image description here

  • click on (+) and setting URL-Schemes as following:

enter image description here

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:-

enter image description here

That all process working fine like:-

enter image description here

查看更多
一夜七次
3楼-- · 2019-05-23 23:41

i think its possible by using Remote notification(ios7 new background method) without showing uialertview interface.....

查看更多
劳资没心,怎么记你
4楼-- · 2019-05-23 23:53

As per iOS limitation we can't able to open any app without user interaction. If you need to open any app then you either force the user to do buy sending push notification where user could able to see your notification and can click to view the app.

Also for opening the app from another app or from a link then you can follow the URL schema method like Nitin Gohel explained above.

If you need to fetch a certain data without user interaction then you can use silent push notification which is commonly called as background fetch. You need to enable the push notification in the background mode and use application:didReceiveRemoteNotification:fetchCompletionHandler: method to handle inside the app. Also we need to make few tweaks in the server side while sending the push notification

    aps { content-available: 1 alert: {...} }

There is lot more stuff available in net regarding background fetch and you can able to understand how it is working in the this link.

查看更多
登录 后发表回答