Using NFC with Flutter on a psychical device Flutter - ios

I'm trying to make NFC work on a iOS phone and now I'm getting this error:
[CoreNFC] 00000002 82426be0 -[NFCHardwareManager areFeaturesSupported:outError:]:154 XPC Error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nfcd.service.corenfc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service named com.apple.nfcd.service.corenfc was invalidated from this process.}
The package I'm currently using is nfc_manager
Here is the code that's being used:
openNFC() async {
// Check availability
bool isAvailable = await NfcManager.instance.isAvailable();
// Start Session
if (isAvailable == true) {
NfcManager.instance.startSession(
onDiscovered: (NfcTag tag) async {
print(tag);
},
);
} else {
print("Your device is not compatible with NFC");
}
// Stop Session
NfcManager.instance.stopSession();
}
Can someone please help me? Thanks in advance❤️

Related

How to use AVCaptureVideoPreviewLayer to display with PiP?

I am trying to use the AVCaptureVideoPreviewLayer with PiP like this:
if #available(iOS 15.0, *) {
let pipVideoCallViewController = AVPictureInPictureVideoCallViewController()
pipVideoCallViewController.preferredContentSize = CGSize(width: 160, height: 160)
pipVideoCallViewController.view.addSubview(videoView)
let pipContentSource = AVPictureInPictureController.ContentSource(
activeVideoCallSourceView: videoView,
contentViewController: pipVideoCallViewController)
let pipController = AVPictureInPictureController(contentSource: pipContentSource)
pipController.canStartPictureInPictureAutomaticallyFromInline = true
pipController.startPictureInPicture()
} else {
// Fallback on earlier versions
}
But I am receiving the following error every time I start the PiP:
-[PGPictureInPictureProxy (0x119965290) _updateAutoPIPSettingsAndNotifyRemoteObjectWithReason:] - Acquiring remote object proxy for connection <NSXPCConnection: 0x28364fca0>
connection to service with pid 64 named com.apple.pegasus failed with
error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to
service with pid 64 named com.apple.pegasus was invalidated from this
process." UserInfo={NSDebugDescription=The connection to service with
pid 64 named com.apple.pegasus was invalidated from this process.}
If I don't connect in the ContentSource, my view present the video but if I connect the layer disappears.

Xcode 9.2 UIDocumentBrowserViewController : Failed to create a url from bookmarkableString

Update: Xcode 9.3 has fixed it.
When creating UIDocument File in UIDocumentBrowserViewController
[default] [ERROR] Could not resolve bookmark. Error: Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not permitted to access the URL." UserInfo={NSLocalizedDescription=The reader is not permitted to access the URL.}
[DocumentManager] Failed to create a url from bookmarkableString (Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not permitted to access the URL." UserInfo={NSLocalizedDescription=The reader is not permitted to access the URL.})
Code work well in Xcode 9.1, But Failed in Xcode 9.2. almost the same code as wwdc 2017.
func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: #escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) {
let newDocumentURL: URL? = R.file.templateDocument()
// Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler.
// Make sure the importHandler is always called, even if the user cancels the creation request.
if newDocumentURL != nil {
importHandler(newDocumentURL, .copy)
} else {
importHandler(nil, .none)
}
}

firebase authentication listener and network connectivity

Test Use Case:
In my scenario, I initialize my App in Xcode, login to firebase and run my app
successfully. I then stop the debugger in Xcode, and then "turn Wifi off" on
my MAC. I then initialize my App again in Xcode.
In the debugger, I see my code initialize an authentication listener and
initialize based on the previously cached value of authenticated user information.
I also see the following exception in the console log.
2017-06-02 09:29:21.281 MusicPoll[7053] [Firebase/Core][I-NET901017] Encounter network error. Code, error: -1009, Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x60800005f7d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}
Since I am not connected to the network, I would like to detect this
condition and ask the user to check his/her network connection and try again.
My question is which Firebase method should I used to check network connectivity and perhaps obtain an error. (I am unable to find an error code that might be
returned in the listener's callback.)
My Code:
...
fileprivate var authListener : FIRAuthStateDidChangeListenerHandle!
FUIAuth.defaultAuthUI()?.providers = [FUIGoogleAuth()]
authListener = FIRAuth.auth()?.addStateDidChangeListener { [weak self] (auth: FIRAuth, user: FIRUser?) in
guard let strongSelf = self else { return }
if let activeUser = user {
strongSelf.hasUserBeenAuthenticated = true
strongSelf.user = activeUser
} else {
strongSelf.hasUserBeenAuthenticated = false
strongSelf.user = nil
}
print("\nFirebaseMgr[setupAuthorization]: hasUserBeenAuthenticated = \(strongSelf.hasUserBeenAuthenticated), user = \(String(describing: strongSelf.user))")
}
You can check the status of the user's internet connection using Firebase's FIRDatabase.database().reference(withPath: ".info/connected") method. This method will observe any changes in network connectivity. Here is an example:
//this is a strong reference to the internet connection handle
var internetConnectionHandle: UInt!
//I have created the observer for internet connectivity in viewWillAppear
override func viewWillAppear(_ animated:Bool) {
let connectedRef = FIRDatabase.database().reference(withPath: ".info/connected")
internetConnectionHandle = connectedRef.observe(.value, with: { snapshot in
if let _ = snapshot.value as? Bool {
//use is connected to the internet.
}
else {
//user is not connected to the internet. Ask the user to check his/her network connection and try again
}
})

Server error while resetting the CloudKit badge

For some weeks now my app is unable to reset the CloudKit badge. I am getting a 'Network Failure' error. It did work before and I have not changed any code. I cannot find anything about changed functionality. Is this a CloudKit bug? Should i file a Radar? Or am I doing something wrong?
Here is the code that I use:
public func setBadgeCounter(count:Int) {
let badgeResetOperation = CKModifyBadgeOperation(badgeValue: count)
badgeResetOperation.modifyBadgeCompletionBlock = { (error) -> Void in
func handleError(error: NSError) -> Void {
EVLog("Error: could not reset badge: \n\(error)")
}
self.handleCallback(error, errorHandler: handleError, completionHandler: {
UIApplication.sharedApplication().applicationIconBadgeNumber = count
})
}
CKContainer.defaultContainer().addOperation(badgeResetOperation)
}
internal func handleCallback(error: NSError?, errorHandler: ((error: NSError) -> Void)? = nil, completionHandler: () -> Void) {
if (error != nil) {
EVLog("Error: \(error?.code) = \(error?.description) \n\(error?.userInfo)")
if let handler = errorHandler {
handler(error: error!)
}
} else {
completionHandler()
}
}
The error that I get with this is:
04/15/2015 09:12:28:837 AppMessage)[10181:.] EVCloudKitDao.swift(202) handleCallback(_:errorHandler:completionHandler:):
Error: Optional(4) = Optional("<CKError 0x7fb451c77c10: \"Network Failure\" (4/-1003); \"A server with the specified hostname could not be found.\">")
Optional([NSErrorFailingURLStringKey: https://ckdevice.icloud.com/api/client/badgeUpdate, _kCFStreamErrorCodeKey: 8, NSDebugDescription: NSURLErrorDomain: -1003, NSLocalizedDescription: A server with the specified hostname could not be found., NSErrorFailingURLKey: https://ckdevice.icloud.com/api/client/badgeUpdate, NSUnderlyingError: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x7fb45351a890 {NSErrorFailingURLStringKey=https://ckdevice.icloud.com/api/client/badgeUpdate, NSErrorFailingURLKey=https://ckdevice.icloud.com/api/client/badgeUpdate, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}, _kCFStreamErrorDomainKey: 12])
04/15/2015 09:12:28:839 AppMessage)[10181:.] EVCloudKitDao.swift(788) handleError:
Error: could not reset badge:
<CKError 0x7fb451c77c10: "Network Failure" (4/-1003); "A server with the specified hostname could not be found.">
A complete functional app with this problem can be found at https://github.com/evermeer/EVCloudKitDao
It's an Apple Bug. I use your Apple based API, timeout a user when attempting to log in from a foreign country. Using VPN from US solves the problem, suggesting Cloudkit isn't friendly to non-US territories. Using the API no problem before, it seems this is their latest change.
Specifically,
CKContainer.fetchUserRecordIDWithCompletionHandler, takes too long or never return.
Reference from Apple Doc
At startup time, fetching the user record ID may take longer while
CloudKit makes the initial iCloud account request. After the initial
fetch, accessing the user record ID should take less time. If no
iCloud account is associated with the device, or if access to the
user’s iCloud account is restricted, this method returns an error of
type CKErrorNotAuthenticated.
#Edwin Vermeer
Please correct me if you have solved it with the updated of your API or Apple fixes it.

QuickBlox downloading content receiving QBASIHTTPRequestErrorDomain code 1

I'm using the iOS SDK to access download content from the content module. It seems in the delegate method -(void)completedWithResult:(Result*)result, I can have cases where result.success is YES while result.file would be nil.
-(void)completedWithResult:(Result*)result
{
if (result.success) { // YES here
if ([result isKindOfClass: [QBCFileDownloadTaskResult class]]) {
FileDownloadTaskResult *res = (QBCFileDownloadTaskResult *)result;
res.file; // This is NULL.
res.errors; // This is an empty NSArray
}
}
}
Console log prints this message:
<QBASIHTTPRequest: 0xc26d200>
headers:(null)
body:
error:Error Domain=QBASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0x9f27a50 {NSUnderlyingError=0x9f18300 "The operation couldn’t be completed. Connection reset by peer", NSLocalizedDescription=A connection failure occurred}
Is this normal? I would expect in this case res.success a NO.
Let's try latest version of iOS SDK 1.8
http://quickblox.com/developers/IOS#Framework_changelog:
Here is one big change:
replaced core network library ASIHTTPRequest with AFNetworking

Resources