Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #319: tapping the widget opens the app #334

Merged
merged 3 commits into from
Dec 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Loop Status Extension/StatusViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@ class StatusViewController: UIViewController, NCWidgetProviding {
super.viewDidLoad()
subtitleLabel.alpha = 0
subtitleLabel.textColor = UIColor.secondaryLabelColor

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(openLoopApp(_:)))
view.addGestureRecognizer(tapGestureRecognizer)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}


@objc private func openLoopApp(_: Any) {
if let url = URL(string: "Loop://") {
self.extensionContext?.open(url)
}
}

func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) {
guard
let context = UserDefaults(suiteName: Bundle.main.appGroupSuiteName)?.statusExtensionContext
Expand Down
9 changes: 9 additions & 0 deletions Loop/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>Loop</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lowercase would be preferred. Any idea if this will create conflicts with another app?

Alternatively you could derive something unique using the bundle identifier, which will be nice for the few folks who have multiple installations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some searching and couldn't find a canonical repository, and since "loop" is 4 characters I'm positive there's a conflict out there somewhere. I just pushed a change to use MAIN_APP_BUNDLE_IDENTIFIER, so the URL now looks like: "com.loopkit.Loop://".

It works in the simulator. Haven't tested it on my device yet.

</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down