2016-03-21 5 views
2

Uygulamamda izleme kitini kullanıyorum. Watchkit aracılığıyla iphone'da uygulamayı açmak istiyorum. Çok aradık ama hiçbir şey bulamadım. Herhangi bir yardım kabul edilecektir.iPhone'da uygulamayı WatchKit uygulamasından nasıl açabilirim?

i de sonra sadece AppDelegate.m Dosya aşağıdaki yöntemi koymak How can I open the parent app on iPhone from my WatchKit app?

+0

Bu eğiticiyi kontrol ettiniz mi? https://www.natashatherobot.com/watchkit-open-ios-app-from-watch/ – UlyssesR

+0

Sağladığınız eğitim linki çok basit, hangi probleminiz var? – EridB

cevap

4

Eğer Objective C ile çalışma varsa linke altında çalıştı.

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply { 
    NSString * request = [userInfo objectForKey:@"requestString"]; 
    if ([request isEqualToString:@"executeMethodA"]) { 
     // Do whatever you want to do when sent the message. For instance... 
     //[self executeMethodABC]; 
    } 
    reply(@{@"clicked from watch":@(1)}); 
} 

Umarım bu size yardımcı olacaktır.

0

Sen AppDelegate dosyasında alıcı mesajı yöntemi (application:handleWatchKitExtensionRequest:reply) uygulamalıdır yöntemini

uygulanması.

Swift: AppDelegate.swift

let message = userInfo.objectForKey("message") as! NSString 
if message.isEqualToString("launchApp") { 
    //Launch functions here 
} 

Objective-C: AppDelegate.m

NSString* message = [userInfo objectForKey:@"message"]; 
if ([message isEqualToString:@"launchApp"]) { 
    // Launch functions here 
} 

Sonuç

1- Sen uygulamalıdır Uygulama Temsilcinizde mesaj alma yöntemi.

2- Swift'de, uygulama temsilcisi AppDelegate.swift'dur.

3- Obj-C'de, uygulama temsilcisi AppDelegate.m'dur.

4- Alınan mesaj yöntemi application:handleWatchKitExtensionRequest:reply dur.