In plist data, if there is only one category mention for example games, then the segmented tab at top will not be shown. To show segmented tab with categories you must have to provide at least 2 categories of apps. Please check the plist file structure to know how to provide app list.
- Showcase apps for cross promotion
- Delegate to integrate analytics to see which app user visits in app store
- Works in both iPhone and iPad
Integrate within a UIViewController:
let bundle = Bundle(for: AppsPortfolioViewController.self)
let storyboard = UIStoryboard(name: "AppsPortfolio", bundle: bundle)
let appsPortfolioVC = storyboard.instantiateInitialViewController() as! AppsPortfolioViewController
appsPortfolioVC.title = "Portfolio"
appsPortfolioVC.loadAppList(name: "sample_portfolio")
self.navigationController?.pushViewController(appsPortfolioVC, animated: true)
Add a custom back button to top left if by default navigation bar is hidden:
let backButton = UIButton(frame: CGRect(x: 10, y: 7, width: 74, height: 30))
backButton.setImage(UIImage(named: "btnBack"), for: UIControlState.normal)
backButton.addTarget(self, action: #selector(goBackFromPortfolio), for: UIControlEvents.touchUpInside)
appsPortfolioVC.view.addSubview(backButton)
@objc private func goBackFromPortfolio(){
self.navigationController?.popViewController(animated: true)
}
Implement delegate to inform when user tap an app:
let bundle = Bundle(for: AppsPortfolioViewController.self)
let storyboard = UIStoryboard(name: "AppsPortfolio", bundle: bundle)
let appsPortfolioVC = storyboard.instantiateInitialViewController() as! AppsPortfolioViewController
appsPortfolioVC.title = "Portfolio"
//assigning analytics delegates
appsPortfolioVC.setAnalyticsDelegate(any: self)
appsPortfolioVC.loadAppList(name: "sample_portfolio")
self.navigationController?.pushViewController(appsPortfolioVC, animated: true)
One delegate method need to implement to know user interaction:
extension ViewController : AppsPortfolio.Analytics{
func appClicked(appNamed: String) {
print("App: \(appNamed) clicked.")
}
}
sample_portfolio.plist file structure:
Add this Swift package to your project
https://github.com/mahmudahsan/AppsPortfolio
-
In your project create a new apps_portfolio.plist file and provide your apps list. Follow the sample_portfolio.plist file format provided in AppsPortfolio/Data.
-
In your project add the icons of your cross promoting apps and mention them in your plist file. Better use Images.assets to add apps's icons.
Feel free to open an issue, or find me @mahmudahsan on Twitter.