I want to get the Channel and User Id from the registration of MCE SDK on the Watson platform. I was able to get the information on Android using the following code:
RegistrationClient client = MceSdk.getRegistrationClient();
RegistrationDetails details = client.getRegistrationDetails(this);
String channelID = registrationDetails.getChannelId();
String userID = registrationDetails.getUserId();
Does anyone knows how to get the same information of the SDK on iOS side? I tried with different ways and the only detail I was able to get is the SDK Version and the App Key with this:
let sdkVersion = MCESdk.shared.sdkVersion()
let appKey = MCESdk.shared.config.appKey
At the end, I was looking on the wrong object, all the details are on the class MCERegistrationDetails.
let appKey = MCERegistrationDetails.shared.appKey
let channelId = MCERegistrationDetails.shared.channelId
let userId = MCERegistrationDetails.shared.userId
Related
I'm trying to make a transaction through Google Pay app. I've implemented this so far:
let paValue = "Client_upi_key" //payee address upi id
let pnValue = "Merchant Name" // payee name
let trValue = "1234ABCD" //tansaction Id
let urlValue = "http://url/of/the/order/in/your/website" //url for refernec
let mcValue = "1234" // retailer category code :- user id
let tnValue = "Purchase in Merchant" //transction Note
let amValue = "1" //amount to pay
let cuValue = "INR" //currency
let str = "gpay://upi/pay?pa=\(paValue)&pn=\(pnValue)&tr=\(trValue)&mc=\(mcValue)&tn=\(tnValue)&am=\(amValue)&cu=\(cuValue)"
guard let urlString = str.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
else {
return
}
guard let url = URL(string: urlString) else {
return
}
UIApplication.shared.open(url)
Now I'm returning to my app & want to have some response like transactionID, userID etc from Google Pay. Is there any way like Android to use Intent in this scenario?
As far as I can see the Google Pay API is only available on Android and Web. Judging from the current docs only showing those options.
If you are looking for a simple payments API, Stripe I know is quite easy to implement. You could also try the Apple Pay SDK.
I am creating a chat app, for which I need to check each of my contact list members if they are registered with my app and show the registered members list in my app.
Currently I am calling an API to check every number one by one. In case of 800 contacts it is getting called 800 times. I know this is not best way to do it. So, can some one please help me out and suggest me to do it in better way?
Below is my code:
func createContactNumbersArray() {
for i in 0...self.objects.count-1 {
let contact:CNContact! = self.objects[i]
if contact.phoneNumbers.count > 0 {
for j in 0...contact.phoneNumbers.count-1 {
print((contact.phoneNumbers[j].value).value(forKey: "digits")!)
let tappedContactMobileNumber = (contact.phoneNumbers[j].value).value(forKey: "digits")
let phoneNo = self.separateISDCodeMobileNo(mobileNo:tappedContactMobileNumber as! String)
contactNumbersArray.append(phoneNo.1)
}
}
}
callGetAppUserDetailService(mobileNumber: self.contactNumbersArray[currentIndex] as! String)
}
I am doing this whole process in the background and refreshing the member list on front in current scenario.
I want to make the whole process as fast as Whatsapp.
There is no way to do it without back-end modifications. So you need to work closely with your back-end engineer and build an API for this.
Here is an advise how you can build this API:
To have 2 APIs:
1) Upload the whole user address book to the back-end in a single request, something like:
let addressBook = NSMutableOrderedSet()
let contact1 = AddressBookContact()
contact1.name = "Jony Ive"
contact1.phone = "1-800-300-2000"
addressBook.add(contact1)
let contact2 = AddressBookContact()
contact2.name = "Steve Why"
contact2.phone = "412739123123"
addressBook.add(contact2)
let deviceUDID = nil
Request.uploadAddressBook(withUdid: deviceUDID, addressBook: addressBook, force: false, successBlock: { (updates) in
}) { (error) in
}
2) As a next step - retrieve a list of already registered users with phones from your address book, something like this:
let deviceUDID = nil
Request.registeredUsersFromAddressBook(withUdid: nil, successBlock: { (users) in
}) { (error) in
}
so now you can show it in UI
Found this example here https://developers.connectycube.com/ios/address-book
In fact,you can do little on client.
The normal way is: Server provide an interface that support check a phonenumber array, and return the phonenumbers has registered on server.
I think you need to save user's phone number to your database when user registers your app. Then you can find out contacts which have already used your chat app.
I'm trying unsuccessfully to get a userToken for Apple Music SDK using the developerToken from JWT. I've used pelauimagineering/apple-music-token-generator and I could get a valid and static userToken. But apple recommend to make dynamic, so I'm trying to use JWT again.
Someone can tell me please what's wrong with my code? Thank you
func fetchDeveloperToken() -> String? {
func fetchDeveloperToken() -> String? {
let iat = Date().timeIntervalSince1970
let days = TimeInterval(24*60*60*120) //120 days
let exp = TimeInterval(iat + days)
let kid = "TBESJXXXXX"
let iss = "KQ6Z6XXXXX"
let alg = "ES256"
let secret = "MIGTAgEAMBMGByqEU7ZHQsoVfmKCCxS5W6BnCgCgYIKoZIzj0AAQcggNoN7dTkNG/8timkkf+Z2toogAqN41YgOXXXXXXXXXXXXXXXXXXsecretkey"
let header:[AnyHashable:Any] = ["alg":alg, "kid":kid]
let payload:[AnyHashable:Any] = ["iss": iss,
"iat": iat,
"exp": exp]
let algorithm256 = JWTAlgorithmHS256()
return JWT.encodePayload(payload, withSecret: secret, withHeaders: header, algorithm: algorithm256)
}
Apple requires you to use the ES256 algorithm, not HS256, I ran into the same issue too. The JWT libray that you're using doesn't support ES256 as you can see here. The only other library on iOS that is listed that supports it is this one
I am using AWS Cognito. The scenario is very simple. The user is prompt to enter a username, password, email address and phone number. The requirement is that when the user presses Sign Up button, a confirmation email is sent to the provided email address. After confirmation, he gets successfully signed up.
Things did till now:
Created Xcode project and installed the necessary pods.
Set up user pool by following AWS official docs.
Set up configuration by using the following code:
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .######, identityPoolId: "######")
let configuration = AWSServiceConfiguration(region: ######, credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
Used the following code for making users sign up.
#IBAction func SignUpClicked(_ sender: UIButton) {
let userName = textFieldUsername.text
let emailAddress = textFieldEmailAddress.text
let phoneNo = textFieldPhoneNo.text
let password = textFieldPassword.text
let userPool = AWSCognitoIdentityUserPool(forKey: "myApp")
let name = AWSCognitoIdentityUserAttributeType()
name?.name = "name"
name?.value = userName
let phone = AWSCognitoIdentityUserAttributeType()
phone?.name = "phone_number"
phone?.value = phoneNo
let email = AWSCognitoIdentityUserAttributeType()
email?.name = "email"
email?.value = emailAddress
userPool.signUp(userName!, password: password!, userAttributes: [name!, phone!, email!], validationData: nil)
}
What am I supposed to do next? Did I miss anything?
I searched a lot but the content found was in objective c or related to signing up using identity providers. So it didn't help!
Swift examples are hard to come by but you can try these -
https://github.com/BruceBuckland/SignIn-awsmhh
AWS Cognito User Pools in iOS (Swift) app
In Swift
You could use as a reference while writing code, you could also take a look codes which is both in Objective C and Swift.
CognitoYourUserPools-Sample References
https://github.com/awslabs/aws-sdk-ios-samples/tree/main/CognitoYourUserPools-Sample
My app has the publish-permission:"publish_actions" and the read-permissions: "public_profile", "email", "user_posts".
After posting an open graph action i want to find out what visibility setting the post has (private, friends, public).
I am calling the following method (Swift)
let request2 = FBSDKGraphRequest(graphPath: "postid", parameters: nil, HTTPMethod: "GET")
request2.startWithCompletionHandler(...)
EDIT:
i receive the following response:
{
data = {
location = {
id = 00000000000;
title = "Sample title";
type = "my_namespace:location";
};
};
"end_time" = "2016-02-01T09:35:35+0000";
id = postid;
"start_time" = "2016-02-01T09:35:35+0000";
type = "my_namespace:check_in";
}
So there does not seem to be a privacy information i get from the post.
Is there a way to get it? According to developers/facebook there should be a privacy field.
So this took me forever to find out. Here is the solution:
When you post an Open Graph Story you get an id as response. This id alone however will not be sufficient when retriving info about it. You need to append the facebook user id at the beginning of the received postid. So the correct id is "userid_opengraphpostid" (underscore needed). The you can make the request with the parameter ["fields":"privacy"] (swift, ios).