locationManeger.requestWhenInUseAuthorization() - swift3

Hi all I am on a tutorial for maps but it is using Xcode 7 in the tutorial.
In the tutorial he uses this link but it has been stopped in the new version.
Can anybody let me know the best way to duplicate this?
I have added NSLocationWhenInUseUsageDescription in the plist.
func locationAuthStatus() {
if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
map.showsUserLocation = true
}else {
//cant get this to work in ios10
locationManager.requestWhenInUseAuthorization()
}
}
Any help will be appreciated.

solved....
I realised that I had created a constant named locationManager but spelt it lacationManager instead, I couldn't work out why it was asking me to change it to LacationManager then I realised the spelling mistake.
all works fine now.

Related

How to turn on showPhysics in a Swift UI SpriteView?

I have been playing with the SpriteView in iOS14 and its working quite well however, I noticed that some collisions that worked fine when using a UIViewcontroller would be missed using the SpriteView. So I thought to turn on showsPhysics to help with the debug. However I am stumped as to how I can do that as the skView is not available?
Can anyone help, I must be missing something.
cheers
S
So now I feel a bit dumb. The answer was to put the view.showsPhysics = true into the didMove(to view: SKView) call!
it is simple, you just need to add a new parameter wend you initialize the SpriteView:
SpriteView(scene: SKScene(), debugOptions: .showsPhysics)

SwiftUI - open link from my website in the app

I have one SwiftUI - iOS app running, and I need to open the link from email/whatsapp/etc in my app.
So lets say the link is like this (from my website):
https://www.mapplebook.com/welcome;id=123
I have tried the custom Scheme, which works fine, but for that i need to do something like: myScheme://www.mapplebook.com/etc....
Which is bad because Website and Android only understand things without the scheme.
The universal link looks like the best approach, I read a couple of things about Apple docs and some other questions, but could not make it work. :(
Is there any suggestion? Maybe some tutorial that I am missing.
Any help is much appreciated.
Editing the question as requested:
This is my info.plist - In this case I am using the custom scheme mapplebook
In SceneDelegate.swift, I have the followng:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
if let range = url.absoluteString.range(of:"https//www.mapplebook.com/id=") {
let sharedtoken = url.absoluteString[range.upperBound...]
//with sharedtoken i can redirect internally and open the correct view - working okay
}
}
But, as mentioned, that uses scheme mapplebook right?
Is it possible to have something like in android, where we say like:
android:host="mapplebook.com"
android:pathPattern="/something"
android:scheme="https" />
So it ask to open the https://mapplebook.com/something url in my app.
Thank you Koen for helping.

translate a variable (which is used in Text())

i have this code here. Normally it is just a Text(question), but then the contents of my variable question will not be translated. There must be a better way...but i don't know how.
Of course "question" will have diffent contents...
if question == "text to be translated" {
Text("text to be translated") // works
} else {
Text(question) // does not work
}
Here is possible variant (old good NSLocalizedString) that still works (tested with Xcode 11.3 / iOS 13.3)
Text(NSLocalizedString(question, comment: ""))
other possible variant (tested in same environment) is
Text(LocalizedStringKey(question))

AWS and Changes in Swift 3

After the Swift 3 update, I'm having some trouble getting my app to compile. Most of the errors are pretty simple to fix, but I'm running into a few in particular with AWS. Is there some sort of updated AWS SDK for Swift 3? I've tried to look it up, but haven't found one. In any case, the two main errors I'm having trouble resolving are as follows:
"Type 'IdentityProviderManager' does not conform to protocol AWSIdentityProviderManager." This is for a class I created following a tutorial to set up logins through AWS Cognito. The code is:
class IdentityProviderManager: NSObject, AWSIdentityProviderManager{
var tokens : [NSString : NSString]?
init(tokens: [NSString : NSString]) {
self.tokens = tokens
}
#objc func logins() -> AWSTask<AnyObject> {
return AWSTask(result: tokens as AnyObject)
}
}
In the AWS documentation for AWSIdentityProviderManager, it says that the only required function is logins, which I have. Is there a simple way to resolve this that I'm missing?
The other error is in my LoginViewController class: "Type 'LoginViewController' does not conform to protocol 'AWSCognitoIdentityPasswordAuthentication'." Here the issue seems a bit more clear, since the documentation says that getPasswordAuthenticationDetails() is a required method and XCode seems to have changed this method to getDetails() when updating to Swift 3, unless I'm mistaken and it wasn't there to begin with or something. In any case, autocomplete doesn't give me the original method and I can't seem to make the class conform to the protocol.
Apologies if the answer is already in documentation somewhere, but as far as I can tell it seems like the AWS SDK (at least the version that I have) is somehow incompatible with Swift 3. Is there something I can do to resolve these errors?
Nevermind, it turned out XCode just wasn't showing me the option to make the changes I needed. The automatic fix implemented slightly different versions of the required functions and everything ended up working.

Getting list of contacts with gloox

I have followed the included example within the gloox source code but cannot get it to work, nor can I find ANYWHERE through Google that's an example of what I am after. I desire a way to obtain the list of added XMPP contacts (roster, I believe?) upon making a connection to an XMPP server. The code I have currently been trying is below:
void GekkoFyre::TuiHangouts::handleRoster(const Roster &roster)
{
Roster::const_iterator it = roster.begin();
for ( ; it != roster.end(); ++it) {
rosterOutBuf.push_back((*it).second->name().c_str());
}
gui_userRosterList(userListWin, rosterOutBuf, 0);
}
Stepping through the code, I can see that this virtual function does not even activate. What am I doing wrong and can anyone offer a solution? Or even better, an example to follow from? Thank you in advance.
P.S.
I don't even know if this code is written correctly, since I cannot debug it if it doesn't activate!
Nevermind, silly me! I fixed the issue with the following code elsewhere:
#include <gloox/rostermanager.h>
Client *client = new Client(jid, passwd);
client->rosterManager()->registerRosterListener(this);
Apologies if I annoyed anyone.