Repository
https://github.com/hitenkmr/TelePost
TelePost - An iOs App
What's about the Project?
TelePost allows users to view news that are the top headlines of the day according to their country. The news is fetched from the News API containing all the news and to let the user get to know what's happening around. This is the just starting of the app which requires the user Steemit account to login into the application. The app uses the News API's to fetch all top news of the day with the user's current region. We are planning to make the app best with Steemit account so that in the future release of the app we can add more features which allow the user to post, vote and comment on posts within the app itself.
Technology Stack
- Xcode
- Swift Programming Language
- Steemit api
- Cocoa Pods
How to fetch News using News API
In TopHeadlinesVC.swift View Controller, we get the current locale to get the region code, which will be used in the News API to fetch the news.
let currentLocale = NSLocale.current
if let regionCode = currentLocale.regionCode {
self.gettopHeadlinesWith(countryCode: regionCode.lowercased())
}
func gettopHeadlinesWith(countryCode: String) {
self.startAnimator()
APIMaster.getTopHeadlinesWith(countryCode: countryCode, completion: { (json, httpResponse) in
DispatchQueue.main.async(execute: {
self.stopAnimator()
})
guard let json = json else {
self.showAlertWith(title: "Error", message: Messages.UnableToLoadfeeds)
return
}
if httpResponse.statusCode == 200 {
if let articles = json["articles"] as? [[String : Any]] {
var headlines = [TopHeadline]()
articles.forEach({ (article) in
let articleModel = TopHeadline.init(info: article)
headlines.append(articleModel)
})
self.currentHeadlines = headlines
}
DispatchQueue.main.async(execute: {
self.countryTopHeadlinesCollectionView.reloadData()
})
} else {
var errorMsg = Messages.InternalServerError
if let message = json["message"] as? String {
errorMsg = message
}
self.showAlertWith(title: "Error", message:errorMsg)
}
}) { (error) in
DispatchQueue.main.async(execute: {
self.stopAnimator()
self.showAlertWith(title: "Error", message:error.localizedDescription)
})
}
}
In API.swift we have a method that will be passed with the countryCode parameter
func getTopHeadlinesWith(countryCode : String, completion : APICompletionHandler, failure : APIFailureHandler) {
let urlStr = "https://newsapi.org/v2/top-headlines?country=\(countryCode)&apiKey=\(NewsApi.key)"
let url = URL.init(string: urlStr)
let request = URLRequest.init(url: url!)
self.forwardRequest(request: request, httpMethod: HttpMethods.HttpMethod_GET, completion: completion, failure: failure)
}
Now on completion handler, we will get the callback to get the JSON data, which is then used to show the news in the collectionview.
How to run the app
The app is currently not available in the app store but still, you can install it on your iPhone. For this you need to match the following requirements:-
Mac
Xcode
Apple developer account
If you match all the requirements, then download the repository to your system, open xcworkspace file in Xcode.
Now connect your device to the system, go to Xcode and build the app on your device and enjoy the app.
Roadmap
- To include Steemit news Section into the app that will show hot, trending, new and promoted news blogs.
- To make the News Section even better and include a section that will cover all of the news that the user might be interested in.
- Bypass the Steemit login for users not having a Steemit account.
- To include a section that will include Steemit posts related to news and all that.
- To allow Non-Steemit users create the Steemit Account and then can login into the app after account creation.
- Steemit Users can Upvote through the App.
- Steemit Users can Comment on the post through the App.
- Steemit users can even post on their Steemit account from the App itself.