Map Kit cannot find route between two coordinate in USA - ios

My code:
let req = MKDirectionsRequest()
req.source = MKMapItem.mapItemForCurrentLocation()
req.destination = destination
let dir = MKDirections(request:req)
if dir.calculating {
print("calculating")
} else {
print("Not Calculating")
}
dir.calculateDirectionsWithCompletionHandler() {
(response:MKDirectionsResponse?, error:NSError?) in
When I print error it shows following:
Error Domain=MKErrorDomain Code=1 "Directions Not Available" UserInfo={NSLocalizedFailureReason=Route information is not available at this moment., NSLocalizedDescription=Directions Not Available, MKDirectionsErrorCode=2, MKErrorGEOError=-902}
It always throws the error above.
I cannot get what those error keys are:
MKErrorGEOError = -902
MKDirectionsErrorCode=2
Googled for more info in it couldn't find it.

Related

Xcode HomeKit add device to Home app using X-HM: or code pin

I learn the Homekit to integrate my IOT device.
let payload = HMAccessorySetupPayload.init(url: URL.init(string: "X-HM://XXXXXXXXX"))
let request = HMAccessorySetupRequest()
request.payload = payload
let setupManager = HMAccessorySetupManager()
setupManager.performAccessorySetup(using: request) { (result, error) in
if (error != nil) {
print("Error from addAndSetupAccessories:", [error?.localizedDescription])
} else {
print("The accessory is added.")
}
}
The "X-HM" link is provided by OpenHab but it returned a error:
Failed to perform accessory setup using request: Error Domain=HMErrorDomain Code=17 "(null)"
I find other user say you need set the permission but I cannot set this in Entitlements file. It return error not find this.
“com.apple.developer.homekit.allow-setup-payload”
Question 1:
in the Homekit doc mean, the link must join "MFi Program"?
====
Question 2:
also, i have the pin code, Could i skip the input step in app setup?
i use the below code but this has not option to input the pin code, it need user to input using keyboard.
let setupManager = HMAccessorySetupManager()
setupManager.performAccessorySetup(using: HMAccessorySetupRequest()) { (result, error) in
if (error != nil) {
print("Error from addAndSetupAccessories:", [error?.localizedDescription])
} else {
print("The accessory is added.")
}
}

iOS - TwilioVideo - Unable to connect on call with remote participant

I am developing app with video calling functionality and I am using Twilio Video for that.
Currently using TwilioVideo SDK v4.6.2 and iOS Version 14.x and Above
I am not able to connect to the TwilioVideo room
Below is my code:
func connect() {
guard let accessToken = self.accessToken, let roomName = self.roomName else {
return
}
prepareAudio()
prepareCamera()
let connectOptions = ConnectOptions(token: accessToken) { (builder) in
builder.isDominantSpeakerEnabled = true
builder.isNetworkQualityEnabled = true
if let localAudioTrack = self.localAudioTrack {
builder.audioTracks = [localAudioTrack]
}
if let localVideoTrack = self.localVideoTrack {
builder.videoTracks = [localVideoTrack]
}
if let preferredAudioCodec = TwiloVideoSettingsManager.shared.audioCodec {
builder.preferredAudioCodecs = [preferredAudioCodec]
}
if let preferredVideoCodec = TwiloVideoSettingsManager.shared.videoCodec {
builder.preferredVideoCodecs = [preferredVideoCodec]
}
if let encodingParameters = TwiloVideoSettingsManager.shared.getEncodingParameters() {
builder.encodingParameters = encodingParameters
}
builder.region = "gll"
builder.roomName = roomName
}
self.room = TwilioVideoSDK.connect(options: connectOptions, delegate: self)
UIApplication.shared.isIdleTimerDisabled = true
}
Response in not received from Twilio in either of the methods mentioned below
func didConnect(to room: Room) {
NSLog("Room: \(room.name) SID: \(room.sid)")
if (room.remoteParticipants.count > 0) {
self.remoteParticipant = room.remoteParticipants[0]
self.remoteParticipant.delegate = self
}
self.delegate.videoServiceManagerDidConnectToRoom(name:room.name)
}
func roomDidFailToConnect(room: Room, error: Error) {
NSLog("Failed to connect to a Room: \(error).")
self.delegate.videoServiceManagerFailToConnectRoom(error: error.localizedDescription)
self.leaveRoom()
}
I am not able connect to the room every time and sometimes I get the error mentioned below :
Failed to connect to a Room: Error Domain=com.twilio.video Code=53000 "Signaling connection error" UserInfo={NSLocalizedDescription=Signaling connection error, NSLocalizedFailureReason=SIP error 408}.
When I check the Twilio logs in debug mode I am not getting any error.
Please guide me to rectify if there is any mistake in my code
Twilio employee here. Error 53000 is somewhat vague and could occur due to different things: https://www.twilio.com/docs/api/errors/53000
I'd suggest the following next steps:
try reproducing this error using the iOS Quickstart app (https://github.com/twilio/video-quickstart-ios)
try running our Networktest on the problematic device: https://www.networktest.twilio.com

Swift -GDPR Consent form returns Error: invalid app name

For some reason when I try to load the GDPR Consent form I keep getting the error:
Error: invalid app name.
It happens here :
form.load { [weak self](_ error: Error?) -> Void in
print("Load complete.")
if let error = error {
// *** HERE IS THE ERROR ***
print("Error loading form: \(error.localizedDescription)")
return
}
When I do a global search for invalid app name I get brought to the consentform.html file:
// Set app name.
var appName = formInfo['app_name'] || '';
if (appName.length <= 0) {
formLoadCompleted('Error: invalid app name.');
}
This tells some value from either the googleservice-plist or my info.plist or something else isn't being read correctly but I don't know which value to look at.
Inside my info.plist I have the GADApplicationIdentifier correctly set:
Why is my app's name coming up as nil?
PACConsentInformation.sharedInstance.debugGeography = .EEA
PACConsentInformation
.sharedInstance
.requestConsentInfoUpdate(forPublisherIdentifiers: ["pub-MY_PublisherID"]) { [weak self](error) in
if let error = error { return }
PACConsentInformation.sharedInstance.isRequestLocationInEEAOrUnknown {
if PACConsentInformation.sharedInstance.consentStatus == PACConsentStatus.unknown {
guard let privacyUrl = URL(string: "My_Privacy_URL"),
let form = PACConsentForm(applicationPrivacyPolicyURL: privacyUrl) else {
return
}
form.shouldOfferPersonalizedAds = true
form.shouldOfferNonPersonalizedAds = true
form.shouldOfferAdFree = true
form.load { [weak self](_ error: Error?) -> Void in
print("Load complete.")
if let error = error {
// *** HERE IS THE ERROR ***
print("Error loading form: \(error.localizedDescription)")
return
}
// ...
}
return
}
}
I had to add dig deep to find out the problem but the issue was the CFBundleDisplayName or better yet the Bundle Display Name(red) in the info.plist was blank:
If the Bundle Display Name (red) is blank then the GDPR Consent form will return an error. You can either manually type in your app's name
OR
just DELETE the entire (red)Bundle Display Name k/v field. If you delete it then then the GDPR Consent will resort to use the Bundle Name(yellow).
Whatever you do DON'T make the mistake and delete theBundle Name(yellow) .
Follow these 2 answers for an explanation between the Bundle Display Name and the Bundle Name:
Bundle Display Name explained
Bundle Display Name with pics

Why address posted with place API is not getting set?

I'm adding my interested Place to Google Place with my APP. Place is getting added successfully, but the address field is empty.
Here is Code:
{
GMSPlacesClient.provideAPIKey(googlePlaceAPIKEY)
let placesClient = GMSPlacesClient.shared()
let userAddedPlace = GMSUserAddedPlace()
userAddedPlace.name = "NightClub & Bar"
userAddedPlace.address = "48 Gandhi Road, Bandra, Mumbai, Maharastra"
userAddedPlace.coordinate = CLLocationCoordinate2DMake(19.017615 , 72.856164)
userAddedPlace.phoneNumber = "9999999999"
userAddedPlace.website = "http://www.google.com/"
userAddedPlace.types = ["bar"]
placesClient.add(userAddedPlace, callback: { (place, error) -> Void in
if let error = error {
print("Add Place error: \(error)")
return
}
if let place = place {
print("Added place with placeID \(place.placeID)")
}
})
}
I can see "NightClub & Bar" in my place list but the address "48 Gandhi Road, Bandra, Mumbai, Maharastra" is not there.
Can anyone tell me what mistake I made?

Playing a single midi note from gs_instruments in iOS / Swift

I'm looking to play a single midi note on an iOS app using Swift.
Here's what I have so far, but unfortunately this crashes with an error.
func initAudio(){
let engine = AVAudioEngine()
self.sampler = AVAudioUnitSampler()
engine.attachNode(self.sampler!)
engine.connect(self.sampler!, to: engine.outputNode, format: nil)
guard let soundbank = NSBundle.mainBundle().URLForResource("gs_instruments", withExtension: "dls") else {
print("Could not initalize soundbank.")
return
}
let melodicBank:UInt8 = UInt8(kAUSampler_DefaultMelodicBankMSB)
let gmHarpsichord:UInt8 = 6
do {
try self.sampler!.loadSoundBankInstrumentAtURL(soundbank, program: gmHarpsichord, bankMSB: melodicBank, bankLSB: 0)
}catch {
print("An error occurred \(error)")
return
}
self.sampler!.startNote(60, withVelocity: 64, onChannel: 0)
}
Here's the error message:
Unable to start playing the low note. Error code: -10867 'ç’ˇˇ'
2015-11-25 15:10:07.419 Demo[774:139850] 15:10:07.418 ERROR: [0x19eaf4000] AVAudioUnitMIDIInstrument.mm:103: -[AVAudioUnitMIDIInstrument startNote:withVelocity:onChannel:]: error -10867
2015-11-25 15:10:07.419 Demo[774:139850] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -10867'
Solution
The AVAudioEngine needs to be started before usage (error -10867 means "not initialized").
Add try engine.start() inside the Do-Catch:
do {
try engine.start()
try self.sampler!.loadSoundBankInstrumentAtURL(soundbank, program: gmHarpsichord, bankMSB: melodicBank, bankLSB: 0)
}catch {
print("An error occurred \(error)")
return
}
About the error code
In your error message there's this line:
2015-11-25 15:10:07.419 Demo[774:139850] 15:10:07.418 ERROR: [0x19eaf4000] AVAudioUnitMIDIInstrument.mm:103: -[AVAudioUnitMIDIInstrument startNote:withVelocity:onChannel:]: error -10867
We see that the emitter of the error code is AVAudioUnitMIDIInstrument, which inherits from AVAudioUnit: these things come from the "AudioUnit" framework which is located in OS X's System folder.
AudioUnit 's error codes are defined in this header file:
/System/Library/Frameworks/AudioUnit.framework/Versions/A/Headers/AUComponent.h
The part that is relevant for us:
CF_ENUM(OSStatus) {
kAudioUnitErr_InvalidProperty = -10879,
kAudioUnitErr_InvalidParameter = -10878,
kAudioUnitErr_InvalidElement = -10877,
kAudioUnitErr_NoConnection = -10876,
kAudioUnitErr_FailedInitialization = -10875,
kAudioUnitErr_TooManyFramesToProcess = -10874,
kAudioUnitErr_InvalidFile = -10871,
kAudioUnitErr_UnknownFileType = -10870,
kAudioUnitErr_FileNotSpecified = -10869,
kAudioUnitErr_FormatNotSupported = -10868,
kAudioUnitErr_Uninitialized = -10867,
kAudioUnitErr_InvalidScope = -10866,
kAudioUnitErr_PropertyNotWritable = -10865,
kAudioUnitErr_CannotDoInCurrentContext = -10863,
kAudioUnitErr_InvalidPropertyValue = -10851,
kAudioUnitErr_PropertyNotInUse = -10850,
kAudioUnitErr_Initialized = -10849,
kAudioUnitErr_InvalidOfflineRender = -10848,
kAudioUnitErr_Unauthorized = -10847,
kAudioComponentErr_InstanceInvalidated = -66749,
};
You should still get this to work by connecting the sampler to the AVAudioEngine graph, ie calling AVAudioEngine.attachNode.
The reason this fails specifically is that the engine reference contained inside the sampler is not yet initialized. Calling attachNode does that, and thus it is ok to call startEngine later on.

Resources