HealthKit request authorization failing - ios

I continue to receive this error when I request authorization.
Error Domain=com.apple.healthkit Code=5 "Transaction block failed without an error." UserInfo={NSLocalizedDescription=Transaction block failed without an error.}
I have tried re-adding and removing:
Privacy - Health Update Usage Description, Privacy - Health Records Usage Description, Privacy - Health Share Usage Description
I have tried removing the HealthKit entitlement and adding it again. This flow worked previously, so I have no idea what is going on. Deleting and reinstalling app does not fix the problem either.
The HealthKit UI just never shows. Checking the privacy settings doesn't show I've ever requested either.
final class HealthStore {
private let healthStore = HKHealthStore()
func requestAuthorization() {
let objectTypes: Set<HKObjectType> = [
.activitySummaryType()
]
healthStore.requestAuthorization(toShare: nil, read: objectTypes) { (success, error) in
print("success = \(String(describing: success))")
print("error = \(String(describing: error))")
}
}
}
In a sample application this code works just fine. I think HealthKit has gotten into a bad state.

I don't know the underlying problem, but restarting my Mac and my iPhone solved the problem.

You change your IP and the network.

Related

Google Firebase not working in iOS App, XCode. Auth.auth.signIn() method not working

I have an iOS app I'm making in XCode, and I am using Google Firebase as the backend. When I run my program, the debug console prints:
2021-03-07 13:39:43.783572-0800 Magnet[12265:425578] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
and then about 5-10 seconds later it gives me these connection errors:
2021-03-07 13:39:53.837553-0800 Magnet[12265:425567] Connection 1: received failure notification
2021-03-07 13:39:53.838667-0800 Magnet[12265:425567] Connection 1: failed to connect 3:-9816, reason -1
2021-03-07 13:39:53.839105-0800 Magnet[12265:425567] Connection 1: encountered error(3:-9816)
After these connection errors print, I find that Firebase's login method no longer runs the code I wrote after the method, which looks like this in my code:
Auth.auth().signIn(withEmail: email, password: password) { [weak self] authResult, error
in
//MY CODE THAT NO LONGER RUNS AFTER CONNECTION ERRORS ARE PRINTED
if error != nil {
//create account here
//self.performSegue(withIdentifier: "toRegister", sender: nil)
print("WRONG! Account doesn't exist")
} else {
print("ACCOUNT EXISTS")
KeychainWrapper.standard.set((authResult?.user.uid)!, forKey: "KEY_UID")
self?.performSegue(withIdentifier: "ViewFeed", sender: nil)
}
}
Is my application not set up with Google Firebase correctly? From what I can tell, there is some connection issue preventing my application from connecting to google firebase in order to verify the email and password that was given by the user

App does not support leaderboards - iMessage App

I have an iMessage app, and trying to get Leaderboard scores. I am getting error:
Error Domain=GKErrorDomain Code=3 "The requested operation could not
be completed due to an error communicating with the server."
UserInfo={GKServerStatusCode=5043, NSLocalizedDescription=The
requested operation could not be completed due to an error
communicating with the server., NSUnderlyingError=0x600000ed3960
{Error Domain=GKServerErrorDomain Code=5043 "status = 5043, MyApp does
not support leaderboards" UserInfo={GKServerStatusCode=5043,
NSLocalizedFailureReason=status = 5043, MyApp does not support
leaderboards}}}
Please note that my app is live, game center is enabled and it has been days since leaderboards were created on iTunes Connect.
func getScoreLeaderboard(leaderboardIdentifier:String, completion:#escaping ((_ resultScore:GKScore?) -> Void)) {
let leaderBoardRequest = GKLeaderboard()
leaderBoardRequest.identifier = leaderboardIdentifier
leaderBoardRequest.loadScores {
(resultGKScore, error) in
guard error == nil && resultGKScore != nil else {
completion(nil)
return
}
completion(leaderBoardRequest.localPlayerScore)
}
}
I have a doubt, but not sure it can be the problem. Problem might be:
I have an iMessage app with Bundle ID e.g. com.mygame. On iTunes Connect, I made a test app to check in app purchase issue encountered. And its Bundle ID is com.mygame.MessagesExtension.
I think that it is trying to get Leaderboard from app with extension bundle ID. Can it be possible? Since my app com.mygame is live, I am unable to delete extension test app, though it is not being used.
Any help is appreciated.
I confirm that Leaderboard was being retrieved from test app instead of actual one. I end up implementing scores management via Firebase instead of Game Center. Apple customer services are pathetic.

Getting error of "Publisher identifiers not found" when I enable "debugGeography" in AdMob

I am trying to test my GDPR compliance code and trying to display the consent form for AdMob but I get this error:
Consent info update failed. Error: Error Domain=Consent Code=1
"Response error. Publisher identifiers not found: ca-app-pub-0123456789012345"
I have triple checked, my publisherID is correct, it is something like "pub-0123456789012345".
When I check my AdMob account status I see that
"Your account is active and in good standing."
I have followed the directions of Google to receive user consent for personalized ads. I am in the USA, so use this line:
PACConsentInformation.sharedInstance.debugGeography = .EEA
When I disable this line, I don't get the error above anymore, but the error below:
Error loading form: Error: request is not in EEA or unknown.
I have tried to use this line instead but nothing changed:
PACConsentInformation.sharedInstance.debugGeography = PACDebugGeography.EEA
My only guess is that for the reason that my AdMob account is USA based, I get "publisherID not found" error when I enable ".EEA". But how can I do the testing if my guess is true?
I am doing the testing both on simulator and on the phone. I could not manage to display the consent form anywhere.
The code I am using is below:
// advertiseIDOfPhone and publisherID are constants defined elsewhere
PACConsentInformation.sharedInstance.debugIdentifiers = [advertiseIDOfPhone]
PACConsentInformation.sharedInstance.debugGeography = .EEA
PACConsentInformation.sharedInstance.requestConsentInfoUpdate(forPublisherIdentifiers: [publisherID])
{(_ error: Error?) -> Void in
if let error = error {
// Consent info update failed.
print("☢️ Consent info update failed. Error: \(error)")
} else {
print("☢️ Consent info updated.")
// Consent info update succeeded. The shared PACConsentInformation
// instance has been updated.
switch PACConsentInformation.sharedInstance.consentStatus {
case .nonPersonalized:
print("☢️ Personalized ads consent NOT given.")
case .personalized:
print("☢️ Personalized ads consent given.")
case .unknown:
print("☢️ Unknown consent.")
guard let privacyUrl = URL(string: "yourWebsiteURL"),
let form = PACConsentForm(applicationPrivacyPolicyURL: privacyUrl) else {
print("incorrect privacy URL.")
return
}
form.shouldOfferPersonalizedAds = true
form.shouldOfferNonPersonalizedAds = true
form.shouldOfferAdFree = true
form.load {(_ error: Error?) -> Void in
print("⚛️ Load complete.")
if let error = error {
// Handle error.
print("⚛️ Error loading form: \(error.localizedDescription)")
} else {
form.present(from: self) { (error, userPrefersAdFree) in
if error != nil {
// Handle error.
} else if userPrefersAdFree {
// User prefers to use a paid version of the app.
//buy the pro Version
}
}
}
}
default:
break
}
print("☢️ isRequestLocationInEEAOrUnknown: \(PACConsentInformation.sharedInstance.isRequestLocationInEEAOrUnknown)")
}
}
Where can be my mistake here? Is the code I am using good?
--
It seems that this is a known bug:
Kindly note that we are aware of this issue, and our Engineering team
is already working on a resolution. Rest assured that we are keeping
an eye out on this, and that we will update you for any news regarding
this issue.
Regards, Ziv Yves Sanchez Mobile Ads SDK Team
I didn't expect a bug from Google in such a fundamental aspect of a big product and unfortunately I have spent hours on this problem trying to find my mistake somewhere...
While they work on a resolution, you can use the Google Test Publisher ID:
pub-3940256099942544
My account gives me the error but I was able to use the test ID to implement and test the Consent SDK. Just make sure you switch back to your ID before you distribute the app.
I got the Same Issue!
This is not our Code's fault. Admob not serving ads.
Go to Admob Console
In Home There is Dialog Box: "Don't serve Until PaymentDetails Entered"
Click the Learn more and create an AdSense account
after that enter payment details
That's all they will serve ads after 24 hours after the account verified
I have the same issue.
Until I updated my settings on https://fundingchoices.google.com.
Go to the webpage, select APP on the left side, go in and activate the app you are using.

iOS DeviceCheck API - GenerateToken gives error Code 0

I'm trying to implement the new iOS 11 DeviceCheck API (https://developer.apple.com/documentation/devicecheck), but token generation always fails. I've tried on simulator and iPhone SE, with wifi and mobile data. Apple ID in settings is my normal, non-sandbox account.
This is an existing app for an organization - from the docs it sounds like the only configuration requirement is to make sure App ID is set up in the apple developer portal.
Anyone else having this issue?
The exact error message is:
The operation couldn’t be completed. (com.apple.devicecheck.error error 0.)
This is the code I'm using, nothing fancy.
if #available(iOS 11.0, *) {
let device = DCDevice.current
if (device.isSupported) {
device.generateToken(completionHandler: { (data, error) in
if let token = data{
print("token: \(token)")
}else if let error = error{
print("error: \(error.localizedDescription)")
}
})
} else {
print("devicecheck not supported")
}
}
In my case, this error was caused by my iPhone's time being horribly out of sync. I manually changed the device's time to be the actual, current time (Settings → General → Date & Time). After that, the error went away and I was able to generate tokens.
Your code seems fine to me. The problem is simulator. It won't pass device.isSupported. You need to run it on real device.

Firebase data retrieval sporadically not returning

I am building a project with Firebase that involves users. There is a known Firebase bug where even after a user has been deleted from the Firebase Authentication section, the user is still able to access the app and still has read/write permissions to the database. I believe it has something to do with the token being stored by Firebase on the user's device.
As a work around to this, I have implemented a "user checkup" where my app will check to see if the userID of the logged in user exists in my real-time database. This way all i have to do is delete the userID node from the real-time database and that will cause this checkup to fail and thus log the user out permanently.
The problem i am having is that the call to observeSingleEvent(of: .value...) is sporadically not returning. By this i mean that sometimes it returns immediately as is expected, however sometimes it just doesn't return at all. For example yesterday morning it wasn't working at all. Yesterday afternoon and night it worked fine. Now today it is no longer working again. Code below...
func checkDatabaseForFIRUser(withId: String, callback: #escaping (Bool)-> Void) {
let fireUsersRef = fireRootRef.child("all-users").child(withId)
fireUsersRef.observeSingleEvent(of: .value, with: {(snapshot)-> Void in
print("user check result -> \(snapshot)")
if snapshot.exists() {
print("SNAP EXISTS")
callback(true)
} else {
print("SNAP NOT EXISTS")
callback(false)
}
}, withCancel: {(error)-> Void in
print("CANCEL BLOCK ERROR = \(error) and localized description = \(error.localizedDescription)")
})
}
I have also noticed that during the times when I am unable to retrieve data I am also unable to write anything to the database, it is as if nothing at all works. My Firebase Rules have been set to "Public" so anyone can read/write. And I have a working internet connection on my device
EDIT: everything works fine on Simulator. Issue is only occurring on the actual device
EDIT #2: This issue seems to have subsided, I haven't noticed it for at least a few weeks now
I bet that by the time you are calling observeSingleEvent, you are log out, so probably that's why it is not returning anything.

Resources