taking java http request for firebase function and putting in swift
I have researched this online but nothing seems like the code I have.
I am trying to work with firebase functions with both my android and iOS apps. I followed a tutorial and it worked fine in Android because it was done in Android but I want to do the same in iOS.
I was told that Alamofire, comparable to OkHttp in Android, was the way to go but I am not sure how to take the code I have in android and put it in SWIFT code so that It does the same thing.
Any assistance would be greatly appreciated.
Code that was used in Android
public static final MediaType MEDIA_TYPE = MediaType.parse("application/json");
ProgressDialog progress;
private void payoutRequest() {
progress = new ProgressDialog(this);
progress.setTitle("Processing your payout ...");
progress.setMessage("Please Wait .....");
progress.setCancelable(false);
progress.show();
// HTTP Request ....
final OkHttpClient client = new OkHttpClient();
// in json - we need variables for the hardcoded uid and Email
JSONObject postData = new JSONObject();
try {
postData.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid());
postData.put("email", mPayoutEmail.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
// Request body ...
RequestBody body = RequestBody.create(MEDIA_TYPE, postData.toString());
// Build Request ...
final Request request = new Request.Builder()
.url("https://us-central1-myapp.cloudfunctions.net/payout")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("Authorization", "Your Token")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// something went wrong right off the bat
progress.dismiss();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// response successful ....
// refers to response.status('200') or ('500')
int responseCode = response.code();
if (response.isSuccessful()) {
switch(responseCode) {
case 200:
Snackbar.make(findViewById(R.id.layout),
"Payout Successful!", Snackbar.LENGTH_LONG)
.show();
break;
case 500:
Snackbar.make(findViewById(R.id.layout),
"Error: no payout available", Snackbar
.LENGTH_LONG).show();
break;
default:
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
break;
}
} else {
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
}
progress.dismiss();
}
});
}
EDIT - Conversion
This is what I was able to convert to along with the code submitted by @emrepun:
// HTTP Request .... (firebase functions)
MEDIA_TYPE.setValue("application/jston", forHTTPHeaderField: "Content-Type")
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value)
// parse your JSON here.
let parameters : [String: Any] =
["uid": FIRAuth.auth()!.currentUser!.uid,
"email": self.paypalEmailText.text!]
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: )
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
android swift httprequest
add a comment |
I have researched this online but nothing seems like the code I have.
I am trying to work with firebase functions with both my android and iOS apps. I followed a tutorial and it worked fine in Android because it was done in Android but I want to do the same in iOS.
I was told that Alamofire, comparable to OkHttp in Android, was the way to go but I am not sure how to take the code I have in android and put it in SWIFT code so that It does the same thing.
Any assistance would be greatly appreciated.
Code that was used in Android
public static final MediaType MEDIA_TYPE = MediaType.parse("application/json");
ProgressDialog progress;
private void payoutRequest() {
progress = new ProgressDialog(this);
progress.setTitle("Processing your payout ...");
progress.setMessage("Please Wait .....");
progress.setCancelable(false);
progress.show();
// HTTP Request ....
final OkHttpClient client = new OkHttpClient();
// in json - we need variables for the hardcoded uid and Email
JSONObject postData = new JSONObject();
try {
postData.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid());
postData.put("email", mPayoutEmail.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
// Request body ...
RequestBody body = RequestBody.create(MEDIA_TYPE, postData.toString());
// Build Request ...
final Request request = new Request.Builder()
.url("https://us-central1-myapp.cloudfunctions.net/payout")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("Authorization", "Your Token")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// something went wrong right off the bat
progress.dismiss();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// response successful ....
// refers to response.status('200') or ('500')
int responseCode = response.code();
if (response.isSuccessful()) {
switch(responseCode) {
case 200:
Snackbar.make(findViewById(R.id.layout),
"Payout Successful!", Snackbar.LENGTH_LONG)
.show();
break;
case 500:
Snackbar.make(findViewById(R.id.layout),
"Error: no payout available", Snackbar
.LENGTH_LONG).show();
break;
default:
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
break;
}
} else {
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
}
progress.dismiss();
}
});
}
EDIT - Conversion
This is what I was able to convert to along with the code submitted by @emrepun:
// HTTP Request .... (firebase functions)
MEDIA_TYPE.setValue("application/jston", forHTTPHeaderField: "Content-Type")
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value)
// parse your JSON here.
let parameters : [String: Any] =
["uid": FIRAuth.auth()!.currentUser!.uid,
"email": self.paypalEmailText.text!]
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: )
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
android swift httprequest
add a comment |
I have researched this online but nothing seems like the code I have.
I am trying to work with firebase functions with both my android and iOS apps. I followed a tutorial and it worked fine in Android because it was done in Android but I want to do the same in iOS.
I was told that Alamofire, comparable to OkHttp in Android, was the way to go but I am not sure how to take the code I have in android and put it in SWIFT code so that It does the same thing.
Any assistance would be greatly appreciated.
Code that was used in Android
public static final MediaType MEDIA_TYPE = MediaType.parse("application/json");
ProgressDialog progress;
private void payoutRequest() {
progress = new ProgressDialog(this);
progress.setTitle("Processing your payout ...");
progress.setMessage("Please Wait .....");
progress.setCancelable(false);
progress.show();
// HTTP Request ....
final OkHttpClient client = new OkHttpClient();
// in json - we need variables for the hardcoded uid and Email
JSONObject postData = new JSONObject();
try {
postData.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid());
postData.put("email", mPayoutEmail.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
// Request body ...
RequestBody body = RequestBody.create(MEDIA_TYPE, postData.toString());
// Build Request ...
final Request request = new Request.Builder()
.url("https://us-central1-myapp.cloudfunctions.net/payout")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("Authorization", "Your Token")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// something went wrong right off the bat
progress.dismiss();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// response successful ....
// refers to response.status('200') or ('500')
int responseCode = response.code();
if (response.isSuccessful()) {
switch(responseCode) {
case 200:
Snackbar.make(findViewById(R.id.layout),
"Payout Successful!", Snackbar.LENGTH_LONG)
.show();
break;
case 500:
Snackbar.make(findViewById(R.id.layout),
"Error: no payout available", Snackbar
.LENGTH_LONG).show();
break;
default:
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
break;
}
} else {
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
}
progress.dismiss();
}
});
}
EDIT - Conversion
This is what I was able to convert to along with the code submitted by @emrepun:
// HTTP Request .... (firebase functions)
MEDIA_TYPE.setValue("application/jston", forHTTPHeaderField: "Content-Type")
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value)
// parse your JSON here.
let parameters : [String: Any] =
["uid": FIRAuth.auth()!.currentUser!.uid,
"email": self.paypalEmailText.text!]
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: )
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
android swift httprequest
I have researched this online but nothing seems like the code I have.
I am trying to work with firebase functions with both my android and iOS apps. I followed a tutorial and it worked fine in Android because it was done in Android but I want to do the same in iOS.
I was told that Alamofire, comparable to OkHttp in Android, was the way to go but I am not sure how to take the code I have in android and put it in SWIFT code so that It does the same thing.
Any assistance would be greatly appreciated.
Code that was used in Android
public static final MediaType MEDIA_TYPE = MediaType.parse("application/json");
ProgressDialog progress;
private void payoutRequest() {
progress = new ProgressDialog(this);
progress.setTitle("Processing your payout ...");
progress.setMessage("Please Wait .....");
progress.setCancelable(false);
progress.show();
// HTTP Request ....
final OkHttpClient client = new OkHttpClient();
// in json - we need variables for the hardcoded uid and Email
JSONObject postData = new JSONObject();
try {
postData.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid());
postData.put("email", mPayoutEmail.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
// Request body ...
RequestBody body = RequestBody.create(MEDIA_TYPE, postData.toString());
// Build Request ...
final Request request = new Request.Builder()
.url("https://us-central1-myapp.cloudfunctions.net/payout")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("Authorization", "Your Token")
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// something went wrong right off the bat
progress.dismiss();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// response successful ....
// refers to response.status('200') or ('500')
int responseCode = response.code();
if (response.isSuccessful()) {
switch(responseCode) {
case 200:
Snackbar.make(findViewById(R.id.layout),
"Payout Successful!", Snackbar.LENGTH_LONG)
.show();
break;
case 500:
Snackbar.make(findViewById(R.id.layout),
"Error: no payout available", Snackbar
.LENGTH_LONG).show();
break;
default:
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
break;
}
} else {
Snackbar.make(findViewById(R.id.layout),
"Error: couldn't complete the transaction",
Snackbar.LENGTH_LONG).show();
}
progress.dismiss();
}
});
}
EDIT - Conversion
This is what I was able to convert to along with the code submitted by @emrepun:
// HTTP Request .... (firebase functions)
MEDIA_TYPE.setValue("application/jston", forHTTPHeaderField: "Content-Type")
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value)
// parse your JSON here.
let parameters : [String: Any] =
["uid": FIRAuth.auth()!.currentUser!.uid,
"email": self.paypalEmailText.text!]
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: )
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
android swift httprequest
android swift httprequest
edited Nov 24 '18 at 6:03
LizG
asked Nov 22 '18 at 23:20
LizGLizG
6141919
6141919
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can make a network request similar to your Java version with Alamofire as given below. You should also learn about how to parse JSON with swift. You might want to look at Codable, which makes it easy to parse JSON. Or you can try a framework called "SwiftyJSON", which is handy to handle json requests as well.
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"
]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value) // parse your JSON here.
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439006%2ftaking-java-http-request-for-firebase-function-and-putting-in-swift%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can make a network request similar to your Java version with Alamofire as given below. You should also learn about how to parse JSON with swift. You might want to look at Codable, which makes it easy to parse JSON. Or you can try a framework called "SwiftyJSON", which is handy to handle json requests as well.
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"
]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value) // parse your JSON here.
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
add a comment |
You can make a network request similar to your Java version with Alamofire as given below. You should also learn about how to parse JSON with swift. You might want to look at Codable, which makes it easy to parse JSON. Or you can try a framework called "SwiftyJSON", which is handy to handle json requests as well.
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"
]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value) // parse your JSON here.
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
add a comment |
You can make a network request similar to your Java version with Alamofire as given below. You should also learn about how to parse JSON with swift. You might want to look at Codable, which makes it easy to parse JSON. Or you can try a framework called "SwiftyJSON", which is handy to handle json requests as well.
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"
]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value) // parse your JSON here.
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
You can make a network request similar to your Java version with Alamofire as given below. You should also learn about how to parse JSON with swift. You might want to look at Codable, which makes it easy to parse JSON. Or you can try a framework called "SwiftyJSON", which is handy to handle json requests as well.
let url = "https://us-central1-myapp.cloudfunctions.net/payout"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"cache-control": "Your Token"
]
Alamofire.request(url, method: .get, headers: headers).validate().responseJSON { (response) in
switch response.result {
case .success(let value):
// you fall here once you get 200 success code, because you use .validate() when you make call.
print(value) // parse your JSON here.
case .failure(let error):
if response.response?.statusCode == 500 {
print("Error no payout available")
print(error.localizedDescription)
} else {
print("Error: couldn't complete the transaction")
print(error.localizedDescription)
}
}
}
answered Nov 23 '18 at 1:05
emrepunemrepun
1,4142618
1,4142618
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
add a comment |
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
So with the code above, does it pretty much do what the Android code does that I submitted? or do I still need to parse the json? I have installed Alamofire in my project, but its a first time for me and so is json.
– LizG
Nov 23 '18 at 1:08
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
It is not the exact equivalent of your version, yes you still need to parse JSON. But, I'm afraid, you cant find someone to write the exact code you need for a different platform here. I would advise you to check tutorials on Alamofire, Codable, or maybe SwiftyJSON as well.
– emrepun
Nov 23 '18 at 8:17
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I used your code above and added to it. Can you check it out and see if I got it right, as it is in the Android code above - see Edit - Conversion. Did I miss something?
– LizG
Nov 24 '18 at 5:59
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
I am closing this post as @emrepun did help. For some reason all is not complete at what I was able to do... I will create another post
– LizG
Nov 24 '18 at 22:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439006%2ftaking-java-http-request-for-firebase-function-and-putting-in-swift%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown