Okay, I must be an unbearable noob to iOS programming, using API's or using XCode in general, because apparently changing the API-Keys in my program to any sort of Restricted API Key breaks my program.
I'm building my app using flutter (Writing most of the code in VSCode).
In my pubspec.yaml I have the following dependencies (Just incase it's relevant).
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.15.4
google_sign_in: ^4.1.4
firebase_core: 0.4.4
google_maps_flutter: ^0.5.24+1
geolocator: ^5.3.0
flutter_google_places: ^0.2.4
geocoder: ^0.2.1
http: ^0.12.0+4
intl: ^0.16.1
If I use the unrestricted Web API Key for my program, as the googleMapKay, I have no problems, and the following code works perfectly.
Future<void> _originAutocomplete() async {
Prediction p = await PlacesAutocomplete.show(
context: context,
apiKey: googleMapKey,
mode: Mode.overlay,
language: "en",
location: new Location(last_known_position.latitude, last_known_position.longitude),
radius: 100000,
components: []);
if (p == null) {
print('p is null');
}
originSelected(p);
}
If however I use the ios-app Restricted API-Key for the same line, p is suddenly null. Now I am using firebase, and I've included the GoogleServices.plist in the program correctly. I've updated the API-Key in my AppDelegate.swift in XCode as well, and also updated the API-Key in the program itself.
I've been testing this on a vairety of devices, iphone se, 5s, 8+, and on simulators for ipad pro 12.9" (third generation), and iphone 11 pro max. In all cases, I have the same error, AND it's fixed when using the unrestricted web API's, which I cannot use in the final release build of the product.
I did also verify that the Restricted API-Key is set to only restrict via iOS apps, and that the bundle-identifier of the program is correctly set inside the google API-Key restrictions. (And that there is only application resrictions, no api-restrictions). So I don't THINK that is the problem, but if you can show me a way to test, then I'd appreciate! After a little testing I found the copy of the key inside the AppDelegate file doesn't seem to matter, so that one can be restricted without an issue.
After looking into the documentation for flutter_google_places, apparently this has an innate dependancy for google_maps_webservices which requires a web-api to function. (If I understand correctly this means an unrestricted key?). This does state that the "correct" industry best-practice would be to use a proxy server?
I'm not 100% familiar with this process, or how to do it, or if there's any simple or easy methods to get this working, so any assistance you can provide would be MUCH appreciated!
Google Maps Platform APIs needs to have API key in the request to work properly. API keys are recommended to have restrictions set on them to secure and protect your keys. Please note that there are different type of restrictions that you can use for your API key and these restrictions should match the appropriate services that are using it, or else, it will throw an error.
I can see that you are using the Google places autocomplete widgets for flutter and this seems to use the Places webservice API. Please know that Places Webservice API is not compatible with iOS restrictions since the APIs/SDKs that can only use this restriction is Places SDK for iOS and Maps SDK for iOS. This might be the reason why you are having the issue when using an iOS restricted API key. You might consider just using an API restriction and restrict your key with the Google Maps Platform API your flutter app is using.
Also, on mobile apps that uses Web Service APIs, you can consider the following technics to safeguard yur API keys: Use a proxy server, Obfuscate or encrypt the API key or signing secret and Use CA pinning or certificate pinning to verify the server resources are valid. These are discuss in this link.
Related
When using flutter_appavailability in an iOS environment: Where can I find the String uri of an app (app1) that needs to be entered on the launchApp(String uri) method of a separate app (app2), so as to intend to call the first app?
I have an app I developed in Flutter to run in iOS. I’ll refer to this as app1. Then a have a second separate app also developed in Flutter to run in iOS, which I’ll refer to as app2. Under certain circumstances, app2 should allow the option to launch app1; for this I’m using the Flutter AppAvailability plugin (https://pub.dev/packages/flutter_appavailability) method launchApp(String uri). If it was Android, the String uri would be the Package name used when creating the project; but that doesn’t work for iOS.
Where can I find the app1 String uri that needs to be entered on the launchApp(String uri) method in app2?
After a bunch of tinkering, it ended up just being the name of my app with :// tacked on the end. So for me, the app that I am working on is called climb so I used climb:// as the URI and it worked for me.
On a separate note I pulled from one of the forks of the flutter_appavailability package to take advantage of null safety and android updates. This is the one that I picked: https://github.com/Insight-Timer/flutter_appavailability.git
In my app I'm showing list of applications.Is it possible to find that the array of applications are installed or not in iPhone.
If any possibility is there anyone please provide related code in swift to check the array of applications is installed or not in iPhone.
In the old times you could have used canOpenURL with a library like iHasApp. This only works for apps that register custom deep link schemes, but it was capturing the majority of important apps.
But since iOS 9 there seems to be a limitation to this approach - see How to reset `canOpenURL` limit in iOS9?
In general your app is not allowed to know what else is installed in the system for privacy reasons.
From your sandboxed application
By default from an Application Layer, you are not allowed to use the private API's to check what other applications are installed on your device.
Workarounds
If the target third-party app supports URL schemes. You can check the url scheme they implement using [UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"someScheme://randomText"]] .
(Not recommended)Take a look at private frameworks like /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices LSApplicationWorkspace . There is a method called allInstalledApplications in LSApplicationWorkspace which should work, check runtime headers for more info.
Off topic ~ For MDM devices
Using Mobile Device Management (MDM) protocol, you can use InstalledApplicationList command to get the array of installed applications on the target device. The following is the response for the said MDM command.
I'm developing an app in UWP. I need to send to my printer a RAW string (or file) and get that printed. I succed in using the old RawPrinterHelper from here.
I have some problems verifiyng the app using the Windows App Certification Kit.
I get errors like this one :
API ClosePrinter in winspool.drv is not supported for this application type. MyApp.dll calls this API.
I think that DllImport() in RawPrinterHelper is wrong.
Is there a way to use a diffent RawPrinterHelper or bypass the Windows App Certification Kit in some way?
P.S. I need to publish the app on the Microsoft Store.
If you have already run the WACK test with the release build, then as the error described there are APIs not supported for the windows store app. More details please reference Supported API test.
Is there a way to use a diffent RawPrinterHelper or bypass the Windows App Certification Kit in some way
For print relative features in windows store app, please follow this tutorial and the official sample. This provide alternatives to the windows print relative APIs. Details please reference Printing and documents section of Alternatives to Windows APIs in Universal Windows Platform (UWP) apps.
If you want the print feature with no print dialog you may reference this thread.
I'm developing an App using Ionic.
I want to add get twitter-connect-plugin but to install it I must provide a Fabric Key.
I go to Fabric.io but it force me to download an extension for my IDEs.
Why I need a Fabric Key? Is there a way to get a Fabric Key without installing these plugins?
Mike from Fabric here. The API key is used to help identify apps and the data that flows into Fabric for them - such as crash reports or analytics for Answers. For example, a crash report for your app using a specific bundle id A, API key B and platform D, would be identified differently then bundle id A, API key C and platform D. This is helpful when developers want debug data to not be in the same grouping as production app data.
If you can't or don't want to use the IDE plugin, then you can go through the web onboarding here: https://fabric.io/kits
One thing to note is that Ionic based apps are not officially supported.
I am developing an iOS app using Ionic Framework and Firebase. I have updated Firebase SDK to version 3.x in my project. What I am trying to do is to authenticate the user with Facebook on a real device. Everything works fine when I test it on a browser. However, whenever I run on a real iOS device, I always get the following error:
This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.
On Firebase, I have already added "localhost" and "127.0.0.1" to my authorized domain list. So I am not sure what to do right now.
For your information, I do not use WKWebView in my project.
Does anybody here can tell me how I can solve this? Please advice.
The error "This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console." only prevents signInWithPopup() signInWithRedirect() linkWithPopup() and linkWithRedirect() operations from working. Every other function, including signInWithCredential(), should work.
I believe that you are seeing this error because ionic apps do not have a real domain, and this is a requirement for the 4 functions I mentioned above.
The solution to your problem would be to ignore the error (it is just informational) and not use signInWithPopup signInWithRedirect linkWithPopup or linkWithRedirect. Instead, use a library for OAuth such as ngCordovaOAuth and then use auth().signInWithCredential(...) (see example instructions for Twitter here).
i have same issue but i solved it by creating new firebase project.
Ok, here is my temporary solution:
I import both Firebase SDK v.2.x and Firebase SDK 3.x in my ionic project. I use version 2.x for Facebook authentication on iOS then I use version 3.x to get access to all new features on Firebase such as Storage and so on.
Hopes this helps.