internal error when publishing a stream - ios

I'm using the IOS SDK.
Trying to Publish a stream and getting
Error Domain=OTSessionErrorDomain Code=2000
Code:
session = OTSession(apiKey: kApiKey,
sessionId: kSessionId,
delegate: self)
var error: OTError?
session.connect(withToken: kToken,
error: &error)
let settings = OTPublisherSettings()
settings.cameraResolution = .high
settings.cameraFrameRate = .rate30FPS
guard let publisher = OTPublisher(delegate: self, settings: settings) else { return }
session.publish(publisher, error: &error)
I'm getting the error on session.publish
Any idea what can be the problem?
I cant find any list of internal error options.
When i run the example SimpleVideo app with the same credentials everything works good.
Thanks

You might be able to get it working by very little chance because publishing won't be successful until a client has successfully connected to a session. The correct steps should be:
Attempt to connect to a session
Did connect to a session
Attempt to publish to the connected session
So, you can't call publish right after calling connect method. Instead, you should do publishing in sessionDidConnect:. That is the callback delegate method to ensure that a client has connected a session successfully.

Related

SQRDReaderSDK.shared.authorize() doesn't have callback initially

I currently am unable to authorize the SquareReaserSDK with iOS (Swift).
I have a node instance that takes in an access_token.
I then call listLocations()
I provide the first location_id in the body of a CreateMobileAuthorizationCodeRequest()
I then pass the resulting mobile auth code to the client
After successfully retrieving a mobile auth token and providing that to the below, the first time this is called there is no callback. The block if statement never fires.
Redundant calls results in an authorization_already_in_progress error (the if statement is fired).
SQRDReaderSDK.shared.authorize(withCode: mobileAuthToken) { location, error in
if let authError = error {
print("Authorize SquareReaderSDK", authError.localizedDescription)
} else {
print("Authorize SquareReaderSDK", location)
Defaults[.establishment]?.squareMobileAuthToken = mobileAuthToken as! String
}
}
authorize() endpoint reference: https://developer.squareup.com/docs/api/reader/ios/Classes/SQRDReaderSDK.html#/Authorization
Redundant calls results in:
vvvvv SQUARE ERROR vvvvv
ERROR: Something went wrong. Please contact the developer of this application and provide them with this error code: authorization_already_in_progress
DEBUG CODE: authorization_already_in_progress
DEBUG MESSAGE: Authorization is already in progress. Please wait for SQRDReaderSDK.shared.authorize() to complete.
^^^^^ SQUARE ERROR ^^^^^
At any point while trying to authorize the device, I get the following error when trying to present the checkoutController:
Checkout Failed:
This device is not currently authorized to accept payments with Square.

NEHotspotConfigurationErrorDomain Error on some devices

I've implemented a WiFi auto-join feature in my app -> Click a button and connect to a named SSID. This works on some devices but also fails on others - meaning it won't even show the Apple pop up asking to join the network. The device might be the same device model, same iOS but fails on some and not on others. This is the error that I see being returned when it fails:
Error Domain=NEHotspotConfigurationErrorDomain Code=10 "cannot modify system configuration." UserInfo={NSLocalizedDescription=cannot modify system configuration.
This is the code used to attempt auto-join:
let WiFiConfig = NEHotspotConfiguration(ssid: "MYSSID")
WiFiConfig.joinOnce = true
NEHotspotConfigurationManager.shared.apply(WiFiConfig) { error in
if error == nil {
//success
} else {
//fail
}
}
Any ideas?
Thanks!
Jennie
I figured out this is unique to our devices using an Embedded Event Manager with a SSID prefilled on the register. That SSID cannot be joined to via the Auto-join feature.

How to find what went wrong with Keycloak login in iOS app using AeroGear

I am trying to connect my iOS app to a Keycloak server for authentication purposes and have decided to use AeroGear library to do it. I did the initial setup as described in the Readme and configured everything Server side.
The code I am using to initiate login is this:
let keycloakConfig = KeycloakConfig(
clientId: "testclient",
host: "http://localhost:8080",
realm: "testrealm",
isOpenIDConnect: true
)
let oauth2Module = AccountManager.addKeycloakAccount(config: keycloakConfig)
//let oauth2Module = KeycloakOAuth2Module(config: keycloakConfig, session: UntrustedMemoryOAuth2Session(accountId: "ACCOUNT_FOR_CLIENTID_\(keycloakConfig.clientId)"))
let http = Http()
http.authzModule = oauth2Module
oauth2Module.login {(accessToken: AnyObject?, claims: OpenIdClaim?, error: NSError?) in
print("login successful")
// some other stuff happens here
}
The app takes me to login screen of Keycloak where I put in the user info and it seems like the login works as I get redirected back to my app. But for some reason nothing that should happen doesn't happen afterwards - for example the print to console.
When I tried it in a different app it worked so it must be ok but I don't know how to debug this. The session on Keycloak seems alright so I have no idea what could cause this...
I would appreciate some advice as I am very good at this.

Migration from AlchemyNews to Watson Discovery gives 401 error in Swift V3 com.ibm.watson.developer-cloud.DiscoveryV1 Code=401

Hello I have moved over from AlchemyAPI to DiscoveryV1 but my swift program is getting a 401 error, rror Domain=com.ibm.watson.developer-cloud.DiscoveryV1 Code=401 "Not Authorized" UserInfo={NSLocalizedFailureReason=Not Authorized}
The app was working fine before moving to Discovery and the Bluemix support team have verified the credentials and get no error when running the query in BLuemix
for the sake of it I also added the url into the App transport Security settings which was a guess but it didn't change the error I have added a a screen capture of the App Transport settings
here are the credentials I am using
let wdn = Discovery(username: "my-user-name",
password: "my-password",
version: "2017-03-08")
let environmentID = "envID generated under my account on bluemix"
let collectionID = "collectionID generated under my account on bluemix"
let filter = ""
let query = newsSearchString < variable set later
let aggregation = "term(enriched_text.concepts.text).top_hits(10)"
let numberOfItemsToReturn = 30
let failure = { (error: Error) in print(error) }
let returnEntities = "enriched.url.url,enriched.url.title,enriched.url.author"
[enter image description here][1]
[1]: https://i.stack.imgur.com/5UvJO.png
I created a new app + service, and did not get an unauthorized error. Here are the steps I followed:
I downloaded the Watson Conversation starter from Bluemix. This includes a lightweight Watson project which includes the SDKs and settings necessary to get set up quickly (essentially all you have to do is put your credentials in a config file for the Converation service).
Because that starter has all of the Watson configuration set up, I just imported the DiscoveryV1 service, dragged the Framework over to my project (updated the Build Phase), and typed in the initialization snippet and everything is working for me.

AWS SDK swift com.amazonaws.AWSSNSErrorDomain Code=0 "(null)"

I'm trying to use the AWS SDK to create an endpoint on an application so that I can send push notifications. The push notifications go through when I manually enter the details on the AWS console but I'm trying to register the device from inside the app so that new users can be signed up.
Following the steps on http://docs.aws.amazon.com/mobile/sdkforios/developerguide/setup.html I have created the credentials for the app in the AppDelegate and use these credentials in another class.
The code I'm using to try and access the AWS SNS is :
func subscribeEndpoint(json: JSON)
{
let sns = AWSSNS.defaultSNS()
let request = AWSSNSCreatePlatformEndpointInput()
let user_id = json["id"].string!
request.token = "XXXXX"
request.customUserData = user_id
print("token : \(token) user : \(user_id)")
request.platformApplicationArn = "XXXX"
sns.createPlatformEndpoint(request).continueWithBlock({ (task: AWSTask!) -> AnyObject! in
if task.error != nil {
print("Error dis: \(task.error!)")
} else {
let createEndpointResponse = task.result as! AWSSNSCreateEndpointResponse
print("endpointArn: \(createEndpointResponse.endpointArn)")
}
return nil
})
}
I have tested using the device token generated by the device when registering for notifications (this value works when inputting on the AWS SNS console). The user_id has also been tested and isn't null.
The error I keep getting is
Error dis: Error Domain=com.amazonaws.AWSSNSErrorDomain Code=0 "(null)"
Not really sure what the cause of the problem is but if anyone could help me it would be greatly appreciated. Thanks
This is most likely an authorization error. Are you setting the default service configuration correctly?
When you use AWSSNS.defaultSNS() it loads the configuration from the default configuration object. The credential provider used for the default configuration should assume a role which has permissions to call createPlatformEndpoint from the client.
You can verify it from the IAM console if the role that is assumed has enough permissions.
Thanks,
Rohan

Resources