今天App扩展小工具点击打开包含应用程序 [英] Today App Extension Widget Tap To Open Containing App

查看:135
本文介绍了今天App扩展小工具点击打开包含应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的应用程序+报价实现了一个Today小部件,它在这些:


已知问题:openURL无法在扩展程序中运行。


所以我想我们至少要等到beta 2。


I've implemented a Today widget for my application +Quotes which displays the day's quote within the notification center with the help of these Apple Docs. What I'd like to accomplish is opening the Containing App, in this case +Quotes, when the user taps the +Quotes widget within their Today notification view, not entirely sure what to call this, as Calendar would if you tapped it in the Today view. I've tried overlaying a button over the label which would call -(void)openURL:(NSURL *)URL completionHandler:(void (^)(BOOL success))completionHandler upon it being tapped, then open the Custom URL Scheme I have declared to open the Containing App. The issue is it doesn't open the Containing App.

-(IBAction)myButton:(id)sender {
    NSURL *customURL = [NSURL URLWithString:@"PositiveQuotes://"];
    [self openURL:customURL completionHandler:nil];
}

解决方案

EDIT: Ok, just a little correction here. I got it working with placing a button over the label just like suggested above and the following code:

- (IBAction) goToApp: (id)sender { 
    NSURL *url = [NSURL URLWithString:@"floblog://"];
    [self.extensionContext openURL:url completionHandler:nil]; 
  }

I linked it to a "Touch Up Inside" event. However, this also causes the app to launch when the user scrolls the Today view.

=======================================

I ran into the same issue. However, it seems that there is no solution for now since the release notes for the first beta of iOS 8 mention:

Known Issues: openURL does not work from an extension.

So I guess we will at least have to wait until beta 2.

这篇关于今天App扩展小工具点击打开包含应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆