I'm using ASWebAuthenticationSession authorization for my application.
It works fine before macOS12.4, but occur unresponse's issue.
After "session.start success", Click Cancel or Continue and there is no response.
var session = ASWebAuthenticationSession.init(url: url, callbackURLScheme: "http", completionHandler: completionHandler)
guard let provider = NSApplication.shared.keyWindow!.contentViewController as? FlutterViewController else {
result(FlutterError(code: "FAILED", message: "Failed to aquire root FlutterViewController" , details: nil))
return
}
session.presentationContextProvider = provider
if(!session.start()) {
NSLog("session.start fail");
} else {
NSLog("session.start success");
}
Edit: I just noticed I did not read correctly and missed the fact that this question was for macOS, not iOS. I still hope one of those answers might lead to a solution.
I have noticed 2 things that seem incorrect to me.
The first one is that you need a strong reference for your session. This limitation is only valid for iOS version < 13.0.
This means, the session variable must "outlive" the invoked method it was started in, e.g. setting a session attribute for the whole class.
I cannot see something similar in the code snippet you provided, it looks like a scoped variable to me.
From Apples documentation for this feature:
For iOS apps with a deployment target earlier than iOS 13, your app
must keep a strong reference to the session to prevent the system from
deallocating the session while waiting for authentication to complete.
The second thing is your callback URL scheme seems to be set to https.
The scheme should match your apps bundle ID.
It must be configured in your Info.plist file. Here's an example how to achieve this. It should actually be something like com.company.myappname instead of http. Your authentication provider would also need to redirect to com.company.myappname://someurl to make this work. Please note the :// must not be part of the callback URL scheme, only the part before that.
Related
I've been trying to use the verifyReceipt endpoint to verify in-app purchase transactions with no success.
Here's how I'm doing it.
1. Read the receipt data in iOS (this is copy paste from Apple's documentation):
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
do {
let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped)
print(receiptData)
let receiptString = receiptData.base64EncodedString(options: [])
// sendReceiptToBackEnd(receiptString)
}
catch { print("Couldn't read receipt data with error: " + error.localizedDescription) }
}
2. In the backend, I followed this advice from Apple:
As a best practice, always call the production URL for verifyReceipt first, and proceed to verify with the sandbox URL if you receive a 21007 status code.
So first I try this (python code):
data = {
'receipt-data': receipt_string, # this is what we get from the frontend
'password': settings.APP_STORE_SHARED_SECRET
}
url = 'https://buy.itunes.apple.com/verifyReceipt'
response = requests.post(url, json=data)
response_data = response.json()
status = response_data['status']
Status here is 21007, which is expected according to the advice above. So then I try the sandbox:
url = 'https://sandbox.itunes.apple.com/verifyReceipt'
response = requests.post(url, json=data)
response_data = response.json()
status = response_data['status']
And I get 21002 - which means there's probably something wrong with what I sent.
Initially I was trying to test this using Xcode locally, but I found out later that verifyReceipt doesn't work with this feature because app's are not signed by the App Store. So I deleted the local configs and set the StoreKit Configuration in scheme back to none, and verified the app is using the App Store Connect as it was picking up any changes I made there in the price.
I'm out of ideas on how to debug this further, so I'm wondering could it be because the App & IAPs are not submitted yet? Currently the app is in the "Prepare for Submission" state, and the IAPs are in the "Ready to Submit" state. Or maybe there is something else I'm missing?
Edit: The answer to my question is "yes, you can." I copied and pasted the json and sent it manually using Postman and it worked fine so something is happening in the backend. I'm leaving the question for reference but if someone recommends deleting please let me know.
I saw your edit, but just as a follow-up code 21002 is a "malformed body" response (or theoretically an Apple server issue, but I've only seen it when mangling the receipt data).
You can see the full list of codes and meanings here:
https://developer.apple.com/documentation/appstorereceipts/status
Incidentally, as you build our your server to process iTunes responses you may find this guide useful for processing the receipt on the server:
https://www.namiml.com/blog/app-store-verify-receipt-definitive-guide
I'm trying to authenticate with Uber's API using watchOS 6.2's new OAuth capability ASWebAuthenticationSession:
ASWebAuthenticationSession(url: uberUrl, callbackURLScheme: scheme) { (URL?, Error?) -> in {
print(callbackUrl, error)
if let url = callbackUrl {
let components = NSURLComponents(string: (url.absoluteString))
if let t = components?.queryItems?.filter({$0.name == "code"}).first?.value {
self.token = t
}
}
}
When I run it, an adorable little web browser comes up on the Watch and prompts for a "E-mail or Mobile Number", after entering my e-mail, clicking on "Next" pops up a text entry window which then suddenly disappears, leaving me back at e-mail entry. The subsequent clicks on "Next" brings up a text entry window which only allows me to edit the e-mail address. Password is never an option. I never got the closure to complete, not even with en error.
If I scroll down to "Login with Google", then Google's login page loads, and lets me enter e-mail and password, and the completion block executes (I get a nil token presumably because my Uber account is not a Google one).
I suspect an issue with Uber's login webpage, but can't verify that other than observing that Google's seems to work. Also, I can find no documentation on the callbackURLScheme parameter with respect to watchOS. I create a scheme in the plist as one might with an iOS app, but can't confirm this is the correct procedure. Nonetheless, it doesn't change the fact that the password field will not come up on Uber's oath login page.
Searching StackOverflow for watchOS and ASWebAuthenticationSession produces no results at this point.
Is anyone else trying to do this right now? Has anyone had success? Am I missing something important, or is this simply an error on Uber's part?
I'm trying to implement Firebase Dynamic Linking.
i have created project on firebase console and provided the required
value(prefx and appid).
i also have allowed the association domains from developer console
and it is sucessfully showing true flag.
in xcode i have on the feature of association domain and added the url identifiers etc.
Problem: still the problem i'm facing is that Association Domain Section says
Add the Association Domains feature to your App ID.
don't know whats the reason why i'm getting this error.
The screen shot is also attached for prove.
i have figured this out by searching for long time.
This is basically not a big issues the error
“Add the associated Domains feature to your App ID”
Will go away once you enable the Associated Domains in your APP ID in developer.apple.com. If it doesn’t go away, quit and relaunch the xcode few times and it will work.
reference: https://medium.com/#abhimuralidharan/universal-links-in-ios-79c4ee038272
I had a similar problem. The problem was solved when I turned off and turned on the feature in Capabilities. But then I had several entitlements files in different folders. Steps to combine these files into one:
Open in text editor MY_PROJECT_NAME.xcodeproj\project.pbxproj
Find CODE_SIGN_ENTITLEMENTS and set correct path. Example:
"MY_PROJECT_NAME/Entitlements/MY_TARGET_NAME.entitlements"
I do not recommend using a standard text editor, since it can automatically replace some characters in the file while saving.
You need to add Associated domains to your App Capabilities. Please see screenshot. Add applinks:yourdomain.com
Then Use below code to get Short URL
guard let link = URL(string: "https://www.yourdomain.com/share_location.html?Id=\(RandomID)&uid=\(uid)") else { return }
let dynamicLinksDomain = "yourdomain.page.link"
let components = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
// [START shortLinkOptions]
let options = DynamicLinkComponentsOptions()
options.pathLength = .unguessable
components.options = options
// [END shortLinkOptions]
// [START shortenLink]
components.shorten { (shortURL, warnings, error) in
// Handle shortURL.
if let error = error {
print(error.localizedDescription)
return
}
print(shortURL?.absoluteString ?? "")
}
I have follow this tutorial (https://devdactic.com/ionic-2-push-notifications/#disqus_thread)
I do not receive notification (status sent on ionic.io) on physical iOS Device with TestFlight. (But the token is generated).
app.component.ts and app.module.ts file: https://pastebin.com/HB97KdWL
I have try official tutorial but same problem..
Thank you in advance !
So, there are a bunch of things that could go wrong, especially with ios. Here are some things to look at:
Managing the certificates for the APNS can be rough. If you have
access to an android device, start there since it's a little more
straightforward to get notifications up and running.
Since you're using apps.ionic.io, you have the advantage of checking
to see if you have a push token assigned to a user. (I'm assuming
that you're using auth?) In the Auth tab, select the
user->View->check the push tab to see the token. Also, use the push
service to send a generic push notification to the users to see if
it arrives.
If you have a problem with ios, there's a strong likelihood that
there's something wrong with the certificates... so check for
another tutorial on that. I'd recommend using the Ionic Cloud Services website instead of Devdactics since Ionic is more in-depth. You can find it here: https://docs.ionic.io/services/push/#prerequisites
Make sure that the "Background Notifications" and "Push
Notifications are selected on the General tab in the Xcode project.
Since you're using Ionic, changing anything with 'cordova platform
add ios' can overwrite it. Make sure it looks like this: ![enter
image description here]3
This might be an oversight?...in your code, you have this:
const cloudSettings: CloudSettings = {
'core': {
'app_id': 'XXXXXX' **<-- this should be a value. (not XXXXXX)**
},
'push': {
'sender_id': 'XXXXX', **<-- this should be a value. (not XXXXXX)**
'pluginConfig': {
'ios': {
'badge': true,
'sound': true
},
'android': {
'iconColor': '#ff0000'
}
}
}
};
app_id is something that is covered in the tutorial that you sent. It's under the IOS certificate section. It says, "After going through the Push guide you need to have your App Id from the Identifier you created inside your Apple profile. Copy that ID and open your config.xml and add your ID:" This is the same ID that you'll put in that section of code.
Unfortunately, there are a lot of things that can go wrong with the certificates. I would focus there since the errors that you get can be unannounced.
I am having a problem getting Facebook events in the Facebook app. For example, to open an event with the url "https://www.facebook.com/events/1743847059178738/," I would use the following code:
let facebookURL = NSURL(string: "fb://event/1743847059178738")!
if UIApplication.sharedApplication().canOpenURL(facebookURL) {
UIApplication.sharedApplication().openURL(facebookURL)
} else {
UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/events/1743847059178738")!)
}
}
It will open the Facebook app, but no matter what event I attempt to display I get a screen saying "Unable to load event. It may have been cancelled." I have tried substituting the Facebook URL of an event for that of a profile (e.g., string: "fb://profile/100005906912309") and it works just fine. Am I mistaken in assuming that the numbers at the end of the event's URL are the same as the event's numeric ID?
So I figured out that I could bypass the whole "fb://event..." bit and just go with:
UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/events/1743847059178738")!)
I assumed this would open the link in Safari, but it automatically opened in Facebook in iOS 8.
I'm sorry for the late answer. I'd prefer to write this as comment, but I'm not able to.
First, nice work around. I think it is a perfect fallback if the fb:// scheme fails as it shown in code shared with your question. I've spent a lot of time trying to resolve the same issue. What I've found is that fb://event/{event-id} is no longer supported and it was replaced with fb://event?id={event-id}.
I've used this post as a reference.