Yowza restored status bar too many times - swift

As I call function OpenGC then the leaderboard appears fine, but when I close the Game Center everything is fine, but then I get the following errors in debug:
2018-04-03 01:12:10.143194+0300 app.name[356:38176] [Error] yowza! restored status bar too many times!
2018-04-03 01:12:10.161688+0300 app.name[356:38176] [Error] Extension request cancelled with error: Error Domain=NSExtensionErrorDomain Code=-2 "Extension cancelled by host." UserInfo={NSLocalizedDescription=Extension cancelled by host.}
The code i am using is here:
#IBAction func OpenGC(_ sender: Any) {
let VC = self
let GCVC = GKGameCenterViewController()
GCVC.gameCenterDelegate = self
GCVC.viewState = .leaderboards
GCVC.leaderboardIdentifier = "my.leaderboard"
VC.present(GCVC, animated: true, completion: nil)
}
func gameCenterViewControllerDidFinish(_ gameCenterViewController: GKGameCenterViewController) {
gameCenterViewController.dismiss(animated: true, completion: nil)
I have found same issue but no solution in:
Unity Forum
Really appreciate if anyone has ideas!
Thanks

We've encountered this error as well on our tvOS build (iOS is working fine) using Xcode 10.2.1. Upon further investigation done by a colleague, seems that other tvOS games found on the tvOS AppStore are experiencing the same behavior.
I've filed a bug with Apple, but at the time of writing it seems that nobody managed to fix this so you're better off just submiting it like this until Apple provides a fix for this issue.

Related

OAuth2 Code Parsing Problem in Xcode 11 and Swift 5

I'm working on a school project where I need to implement OAuth2 to get access to our student profiles and display them. The app has two views - a search bar and detailed user info on the next page. I'm fairly new to this, so any advice will be greatly appreciated.
I was mostly following this tutorial https://grokswift.com/alamofire-OAuth2/ but a lot of stuff is deprecated. I can easily get all data using postman and user credentials but when I implement OAuth2 I can't parse the code I receive. So all my functions are in ContentView (pretty sure it's not the right way, but I couldn't make it work otherwise for now). I have a search button that looks like this:
Button(
action: {self.handleAPI()},
label: {
Text("Search")
}
And a handleAPI function that calls other functions, and func startOAuth2Login() among them:
if let authURL:NSURL = NSURL(string: authPath)
{
UIApplication.shared.open(authURL as URL, options: [:], completionHandler: nil)
print("here1")
}
Everything works as expected, redirects me to the login screen, where I enter my credentials, press "Authorize" and successfully return to the app. The print statement is also visible. However, I can't find the link I receive to parse the auth code. I know it should be in AppDelegate and this is what I have for now but it's not being called.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
ContentView.sharedInstance.processOAuthStep1Response(url: url as NSURL)
print("url: \(url)")
return true
}
processOAuthStep1Response(url) is just another function in my handleAPI main function. I also have this line in my ContentView : static let sharedInstance = ContentView().
So the question is how to call my function that will parse the code? How can I even see this code? XCode doesn't give any errors and everything works, just after "here1" nothing else is called. Thank you in advance!

Is there away to completely override a line of code based on a condition set?

I creating this app for my church and one feature is a prayer wall. I am using firebase as my database integrated with google sign in. When a user post a prayer request it displays their display names amongst other things. I implemented a switch and some line of code to change the display name to anonymous if the switch is on. That works however it adds anonymous after the display name. Please see the examples below.
I am really new to swift and I am self taught this is my first app, any help would be greatly appreciated.
#IBAction func didPostPrayerRequest(_ sender: Any) {
var userInfo = Auth.auth().currentUser?.displayName
if privacyFilter.isOn {
userInfo?.append("anonymous")
}
let prayerPosted:[String: Any] = ["praydate": [".sv":"timestamp"], "prayer": prayerPostText.text!,"username":userInfo!]
prayerRef?.child("Prayers").childByAutoId().setValue(prayerPosted)
print("Any")
//Dismiss popover
presentingViewController?.dismiss(animated: true, completion: nil)
}
Screenshot
Simply overwrite the value using userInfo = "anonymous" instead of appending to it.

IBM Watson Visual Recognition API Key fail - Xcode Swift

I'm trying to connect to Watson using VisualRecognitionV3.framework.
The framework's compiled fine (via Carthage), and I think I've got the Service Credentials configured correctly, but when I compile Xcode to the simulator I get an invalid-api-key error.
Has anyone experienced the same issues?
What am I doing wrong?
private let apiKey = "Xn5DUtQU8WzgFTL9qNEFwBjxxxxxxxxxxxxxxxxxx"
private let classifierId = "DefaultCustomModel_2051029379"
private let version = "2018-07-01"
var visualRecognition: VisualRecognition!
override func viewDidLoad() {
super.viewDidLoad()
self.visualRecognition = VisualRecognition(apiKey: apiKey, version: version)
}
override func viewDidAppear(_ animated: Bool) {
let localModels = try? visualRecognition.listLocalModels()
if let models = localModels, models.contains(self.classifierId) {
print("local model found")
} else {
self.updateModel()
}
}
Xcode Error:
Error Domain=com.ibm.watson.developer-cloud.VisualRecognitionV3 Code=403 "ERROR: invalid-api-key" UserInfo={NSLocalizedDescription=ERROR: invalid-api-key}
Watson configuration screenshot:
Watson Config
You need to initialize your VisualRecognition using another initializer, like the following
let visualRecognition = VisualRecognition(version: version, apiKey: apiKey, iamUrl: nil)
The difference is that you will need to call this 3 argument-ed constructor with the third argument, i.e. the iamUrl, even though you make it nil and anything else is the same. This tells the VisualRecognition class to authenticate your app using the IAM.
The git documentation is very confusing, which says in here https://github.com/watson-developer-cloud/swift-sdk#visual-recognition
Note: a different initializer is used for authentication with instances created before May 23, 2018:
Which means the old way should just work, UNLESS, they made a mistake and they actually mean AFTER May 23, 2018
Anyways, if you try it should just work. I was having this issue 30 mins before writing this answer.

Utilizing Mission Control

recently I've gotten into trying to utilize the DJI Mobile SDK as a little side project of mine. I've been working in Swift utilizing the samples provided by DJI on their Github but I've been having an issue utilizing the missionControl and honestly I'm not even sure if missionControl is the best way to go about doing it.
Goal: Simply what I'm trying to achieve is that I just want the drone to fly up to a specified height and take video footage of what is below it. I'm not even concerned with horizontal motion right now, just vertical motion.
What I've Done: Utilizing their sample, I've gotten the drone to record video footage, but I am unable to get it to truly fly. My first approach was to use flightController and I've succeeded in getting it to take off and land, but I do not believe their is a method such as goToLocation() or something of the sort. This is the functioning methods that do take off and landing.
#IBAction func takeOffPressed(_ sender: Any) {
if let aircraft = DJISDKManager.product() as? DJIAircraft {
aircraft.flightController?.startTakeoff(completion: nil)
}else{
self.showAlertViewWithTitle(title:"Action", withMessage: "Product Connection Not Found")
}
}
#IBAction func landPressed(_ sender: Any) {
if let aircraft = DJISDKManager.product() as? DJIAircraft {
aircraft.flightController?.startLanding(completion: nil)
}else{
self.showAlertViewWithTitle(title:"Action", withMessage: "Product Connection Not Found")
}
}
Although I got the drone to takeOff, that is not truly flight so instead I started looking into the missionControl class where there seems to be missions to achieve the functionality that I want, however my code seems to not be correct because it does not cause the drone to perform any action. If there is someone here more experienced with the DJI SDK, I would appreciate any help that you may be able to give. My non functioning code is below.
#IBAction func doMission(_ sender: Any) {
var elements = [DJIMissionControlTimelineElement]()
elements.append(DJITakeOffAction())
elements.append(DJIGoToAction(altitude: 1)!)
elements.append(DJIGoHomeAction())
DJISDKManager.missionControl()?.scheduleElements(elements)
DJISDKManager.missionControl()?.startTimeline()
}
The timeline mission needs a few adjustments, including the altitude of the go to action and the addition of a DJIRecordVideoAction to record video for your desired duration. Try the modified code below:
#IBAction func doMission(_ sender: Any) {
var elements = [DJIMissionControlTimelineElement]()
elements.append(DJITakeOffAction())
elements.append(DJIGoToAction(altitude: 5)!)
elements.append(DJIRecordVideoAction(duration: 10)!) // this assumes a desired duration of 10 seconds
elements.append(DJIGoHomeAction())
DJISDKManager.missionControl()?.scheduleElements(elements)
DJISDKManager.missionControl()?.startTimeline()
}
You can also make use of DJIMissionControl addListener:toTimelineProgressWithBlock: method to add additional diagnostics to your code as it will be called for each timeline event including start and finish of all elements.

Text Input Controller WatchKit

I am trying to use presentTextInputControllerWithSuggestions in a WatchKit app.
I am not sure where I am going wrong.
presentTextInputControllerWithSuggestions(["Hello", "Hey"], completion: {
(myString) -> Void in
println(myString)
})
From the iOS 8.2 Release Notes:
WatchKit
Known Issues
The presentTextInputControllerWithSuggestions:completion: method of
WKInterfaceController is not currently supported in iOS Simulator.
You can try by tapping on a suggestion. It should do exactly the same as dictating.
Beware, the completion returns an array and not a string.
You should do it like that
self.presentTextInputControllerWithSuggestions(["Suggestion 1", "Suggestion 2"] allowedInputMode: .Plain, completion: { (selectedAnswers) -> Void in
if reply && reply.count > 0 {
if let spokenReply = selectedAnswers[0] as? String {
println("\(spokenReply)")
}
}
})
From Apple Dev Forums
Its the same a pressing microphone on the iPhone keyboard and dictating.
The Audio goes off to apple and returns and hopefully the text you spoke is returned as a String.