-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[legacy] adds new check for updated app and provides an in app upgrad…
…e experience (#763) * adds new check for updated app and provides an in app upgrade experience. Signed-off-by: Dan Cunningham <[email protected]> * Update language files Signed-off-by: Dan Cunningham <[email protected]> * Fixed typo Signed-off-by: Dan Cunningham <[email protected]> --------- Signed-off-by: Dan Cunningham <[email protected]>
- Loading branch information
1 parent
0d603de
commit 72c9439
Showing
21 changed files
with
386 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
openHAB/Images.xcassets/Download_on_the_App_Store_Badge_US-UK_RGB_blk.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Download_on_the_App_Store_Badge_US-UK_RGB_blk_092917.svg", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...US-UK_RGB_blk.imageset/Download_on_the_App_Store_Badge_US-UK_RGB_blk_092917.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2010-2024 Contributors to the openHAB project | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0 | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 | ||
|
||
import OpenHABCore | ||
import StoreKit | ||
import UIKit | ||
|
||
class LegacyNoticeViewController: UIViewController, SKStoreProductViewControllerDelegate { | ||
@IBOutlet private var toggleSwitch: UISwitch! | ||
@IBOutlet private var textView: UITextView! | ||
|
||
var appData: OpenHABDataObject? { | ||
AppDelegate.appDelegate.appData | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
toggleSwitch.isOn = !Preferences.promptForUpgrade | ||
textView.text = NSLocalizedString("upgrade_message_body", comment: "Click below to update") | ||
} | ||
|
||
@IBAction func imageClicked(_ sender: Any) { | ||
if let updatedAppId = appData?.updatedAppId, !updatedAppId.isEmpty { | ||
openStoreProductWithiTunesItemIdentifier(appData!.updatedAppId) | ||
} | ||
} | ||
|
||
@IBAction func switchValueChanged(_ sender: UISwitch) { | ||
Preferences.promptForUpgrade = !sender.isOn | ||
} | ||
|
||
func openStoreProductWithiTunesItemIdentifier(_ identifier: String) { | ||
let storeViewController = SKStoreProductViewController() | ||
storeViewController.delegate = self | ||
|
||
let parameters = [SKStoreProductParameterITunesItemIdentifier: identifier] | ||
storeViewController.loadProduct(withParameters: parameters) { [weak self] (loaded, _) in | ||
if loaded { | ||
self?.present(storeViewController, animated: true, completion: nil) | ||
} | ||
} | ||
} | ||
|
||
func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) { | ||
viewController.dismiss(animated: true, completion: nil) | ||
} | ||
} |
Oops, something went wrong.