开发者

Can an iPhone application relaunch itself when terminated?

开发者 https://www.devze.com 2023-01-08 10:28 出处:网络
I have two requirements for my latest project: When the app launches for the first time it should display the device native dialer and then check for callDidConnected in background.

I have two requirements for my latest project:

  • When the app launches for the first time it should display the device native dialer and then check for callDidConnected in background.
  • once the callDidConnected is true app should launch itself.

Here I tried the following logic:

 - (void)applicationDidFinishLaunching:(UIApplication *)application {


 //i am dialing to a IVR from the native dialer

 if (/* A check to validate wether 开发者_运维问答to call or not */)
 {
    NSLog(@"Dialing");

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:"]];


    // A loop check wether the call get connected  
    while (!callDidConnected){
  callDidConnected = // doing a check with server
    }

    // if call get connected then launching my application
    if (callDidConnected){
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"MyApp:"]];
 }

 }

 else
 {
  // normal app
 }
}



 - (void) applicationWillTerminate:(UIApplication *)application
{

}
  • I registered the app with URL MyApp.
  • I tested this code on simulator(on SDK 3.0/3.2) with opening another app(tried http instead of tel protocol). The check executes in background while other native app(safari) run in foreground.

    "So this look a little odd" the Apple guys says.

    Can any one help me to find whether I can use this code in my work, and will it be acceptable by Apple store.


No this is not possible or acceptable.

Think about it: the iPhone would not be able to do anything other than run this app, since it would instantly launch again when you quit it... Sounds like malware to me. Not something I'd ever want on my iPhone, and I'm happy that Apple restrict this kind of thing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号