2017-02-14 8 views
-1

私は、タイマーイベントでバックグラウンドから起きるデモアプリを持っている必要があります。脱獄せずにプライベートAPIを使用することは可能ですか?このコードを試してみました:iOSプライベートAPI:バックグラウンドからアプリを復帰させる

void* sbServices = dlopen(SBSERVPATH, RTLD_LAZY); 
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier"); 
int result; 
result = SBSLaunchApplicationWithIdentifier(CFSTR("com.my.app"), false); 
dlclose(sbServices); 

は最後に、私はプライベートAPIを使用して解決策を見つけた

答えて

0

を働いていたしませんでした。ここでは、10秒ごとにカスタムアプリを起動するコードの例を示します。

@interface PrivateApi_LSApplicationWorkspace 

- (bool)openApplicationWithBundleID:(id)arg1; 

@end 

@implementation ViewController { 
    PrivateApi_LSApplicationWorkspace* _workspace; 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    _workspace = [NSClassFromString(@"LSApplicationWorkspace") new]; 

    NSTimer *timer = [NSTimer timerWithTimeInterval:10.0 repeats:YES block:^(NSTimer * _Nonnull timer) { 
     [self openAppWithBundleIdentifier:@"com.app.my"]; 
    }]; 
    [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode]; 

} 

- (BOOL)openAppWithBundleIdentifier:(NSString *)bundleIdentifier { 
    return (BOOL)[_workspace openApplicationWithBundleID:bundleIdentifier]; 
} 

@end 
+0

上記のコードのプライベートAPIはどれですか? – Hisenberg

+0

LSApplicationWorkspaceクラス – Rost

+0

これはiOS 10で動作していますか? – Hisenberg

関連する問題