Android - Google OAuth 2 - twice response with different verifier code - android

I have an issue with Oauth Google on Android 9 and lower.
Settings :
I develop an application with :
Nativescript 7
Angular 11
nativescript-oauth2:3.0.3 plugin
The problem :
I am not sure the problem is from the nativescript-oauth2 plugin, perhaps my android application configuration or Google Frame.
I develop an OAuth login with Facebook and Google provider.
For Facebook, no problem.
Facebook use a web view browser, and Google use a native view browser.
For Google, see bellow :
on emulator with android 10 : all work fine
on emulator with android 8 or 9 :
it open the browser to login with Google => I choose my account => redirect to a Google Page with Waiting message => it never redirect to my app, and after a moment, it redirect to www.google.com
on real device (android 9) with multiple Google account, I have 2 behaviors :
First : it open the browser to login with Google => I choose my account => redirect to a Google Page with "Waiting" message => redirect to my App with The login operation was canceled error message
Second : it open the browser to login with Google => I wait a moment (per example 1 minute) => I choose my account => redirect to a Google Page with Waiting message => redirect to my App => it work fine
on other real Device with just one account Google (in android settings), it is ok
More details :
I debugged the application and the nativescript-oauth2 plugin.
I saw that the Google Frame with Waiting message (after choose a google account) send 2 events to Android with differents values for the "code" parameter.
Of course the first code is expired/revoked and Google return an error.
In the OAuth Google documentation, this is the Step 4 which send 2 responses with 2 codes.
My question
Why the Google Frame browser send me 2 events ?
Code :
Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:theme="#style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Custom URL Schemes -->
<data android:path="/auth"
android:scheme="com.googleusercontent.apps.xxxxxxxx-yyyyyyyyyyyyyyyyyy"/>
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxxxxxxxxxx" />
</application>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

Related

Firebase dynamic link for not installed application

I have a problem with dynamic link at Firebase not redirecting me to Play Store if the application is not installed.
The dynamic link is defined as following:
The link preview (debug) show following picture:
according to this one if I click on the link and application is not installed I would be brought to Play Store. However it just opens a browser and opens the web link. The "Play Store" link though is functioning and brings me to the Play Store.
One more detail. When I click on the dynamic link on my Android phone I see three steps:
A browser window with "google.com" URL opens shortly.
Browser window is closed and I see original screen where I clicked on the link with a ring rotating for less than a second.
A browser windows opens again but this time with web link opened
And same happens even if the application is installed.
Is there a way to debug this behavior and get some better understanding of what's the reason?
The AndroidManifest.xml is defined as following:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />
<application
android:label="myapp"
android:name="${applicationName}"
android:icon="#mipmap/icon">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="myapp.com" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
As you mentioned it is in debug , i believe here that application is not present on playstore right now and that's why it is not redirecting you to playstore in case of app is not installed on your device but yes , it should open your app if it is already installed on your device
so make sure above scenario .. if flow is working same as mentioned then no worries everything is fine but if it is not working as mentioned then you need to mention code of creating link , manifest file , activity where you are handling it etc ..
So, it turned out my approach to dynamic links building was wrong. Dynamik link creation as shown in the question is a way to establish static links that don't change and have no parameters. It's usable to bring users to a specific part of your application that never changes.
In case of using dynamic link, which is dynamic in its nature like in my case - invitation link that allows to install application if it's not yet installed, run it and bring the user to a specific part of the application with parameters would be:
Define a URL prefix
Publish the application at Play Store at least in closed testing mode. Internal testing seems not to be enough because it's available only by internal testing ID and not the package ID.
Generate URL of type: https://myapp.page.link/?link=https://myapp.com/join/invitation_id&apn=com.myapp
That is enough to make work for Android. For iOS it's not tackled yet.

How to open an Android TV app with voice

Edit
The original post says that I can't open my test by saying "open test". Repeated attempts have shown that it does work...sometimes. Perhaps 90% of the time saying "open test" opens my test app, but the other times it does a media search. I can see the text that google is transcribing, so the two different outcomes aren't being caused by mistakes in the speech-to-text.
Original post
On an Android TV, I am able to open apps by clicking the remote's microphone button and saying "Open <appname>" (e.g. "Open youtube" or "open dailymotion"). I want this functionality in the app I develop. After deploying my app to the TV, I cannot open my app by saying "open test", where "test" is the value of android:label in the application element of AndroidManifest.xml.
I've tried this out with a basic Android-Studio generated TV projected, so my AndroidManifest.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="<my package>"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false"/>
<uses-feature
android:name="android.software.leanback"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="test"
android:theme="#style/Theme.Leanback">
<activity
android:name=".MainActivity"
android:icon="#drawable/app_icon_your_company"
android:label="test"
android:logo="#drawable/app_icon_your_company"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
How do I add this functionality?
I have two thoughts: that there is an Android Manifest property that I haven't found in my search, or that this functionality is only available for apps available in the play store. (If I use the mike to say "open dailymotion" when I don't have dailymotion installed, the top result is a link to the app on the play store, which makes me think this functionality is reliant on being indexed by google.)
You would want to use System voice action https://developers.google.com/voice-actions/system/
https://www.youtube.com/watch?v=OW1A4XFRuyc&list=PLOU2XLYxmsIJDPXCTt5TLDu67271PruEk

After 4 days app is still not indexed in Google Play search

I have published my first application (Voice To SMS) on google play 4 days ago and I still can't find my app in search by it's name or developer name. I can find my app only by package name or by real app name but without spaces - "VoiceToSMS".
Link to my app: https://play.google.com/store/apps/details?id=com.SpeechProcessing.Voice.To.SMS.Converter&hl=en
As we can see, in the bottom of the page there is no even "Similar apps" section...
In Google Play developer console everything seems OK (except that my app is not designed for tablets). 0 errors, I selected all available countries for distribution, app status is "Published". In app description I wrote some keywords.
What could be wrong? Maybe app is not indexed because its name is not specific?
I am attaching manifest.xml additionally:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SpeechProcessing.Voice.To.SMS.Converter"
android:versionCode="2"
android:versionName="1.0.1" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppBaseTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity
android:name="com.SpeechProcessing.Voice.To.SMS.Converter.MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
/>
</application>
</manifest>
Well, more than 2 weeks gone after uploading my app on Google Play. My app is finally searchable by term "voice to sms". In my strong opinion, it wasn't Google-side issue that app wasn't searchable for a while by mentioned term.
I did one SEO trick - in app description I included some keywords whose are popular but not so like "voice to sms". In result, I got more downloads and growing my app's search rank. After few days, my app's rank was enough high that Google could show my app in results of "voice to sms" search term.
So, if you have similar problems - focus on SEO for your app.

google map v2 grey blank page , only zoom is there

I am working in Iran, I had used Google map v1 for long time, now that I have to use Google map v2, I just can see a grey blank page with zoom icon only, I have done every thing based on Google instructions, I think I have done everything.
*I WANT TO KNOW IF THIS PROBLEM IS RELATED TO GOOGLE POLICY THAT MEANS SOME COUNTRIES ARE NOT ALLOWED TO USE GOOGLE PLAY SERVICES AND MAP .... *
THIS IS A BIG PROBLEM FOR ME NOW
THX
this is the manifest file of my code :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pea.map001v2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="your.package.name.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="your.package.name.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.
permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.pea.map001v2.MainMapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCk0HwJYHIjM9W_eqqTB1C5wyB-2B0B5U4" />
</application>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
</manifest>
You Must Run your app in amulator having Following Configuration....
Google API(x86 System image)
Select checkBox indicating "Use Host GPU..."
If anything this could be related to Iran's policy and not Google's.
The problem you describe usually happens when you have a problem with the API key you have generated or the way you registered it in the Console.
You can go over this blog post I wrote on getting the Google API V2 key:
Google Map API V2 key
Maybe, you missed one of this:
Didn't include the Google API Key v2 in the manifest.xml
Didn't add the package name in Android maps Key(Console) , example:
ABczzisierkaiSAisi-Ka2;my.project.package
Didn't add Internet Permissions, on manifest.xml.
Your Android device doesn't have an internet connection
NOTE: If you are using a Virtual Device, it won't work, beacuase it needs Google Play Services
I used to face the same problem as yours. The first thing you need to check is Google Maps Android API Key. Then check the settings in AndroidManifest.xml. There are detail instructions in following link: Android Maps Android v2
yes, it's because of country ._.
i have this issue too on javaScript apis, but it works out with proxy..

C2DM / Phonegap plugin?

I would like to add Push messaging to my Phonegap Android App and believe that C2DM is the waybest way to make this work - could point me in the right direction to set this up?
Is there a plugin or tutorial to help with this?
Also - do I actually need a plugin - is it possible to add C2dm to my app the traditional Android way without messing up my phonegap setup?
Yes, C2DM is the Android Push solution. On https://github.com/awysocki/C2DM-PhoneGap you can find an example implementation.
The files in the com.google namespace have to be included unchanged, they are from the session "Google IO Session Overview: Android + App Engine: A Developer’s Dream Combination", see http://bradabrams.com/2011/05/google-io-session-overview-android-app-engine-a-developers-dream-combination/
So these are the steps you should perform:
Add the 3 com.google classes to your project
Create a class called C2DMReceiver (naming convention) which inherits from C2DMBaseReceiver and implement the necessary abstract events
Set up the AndroidManifest.xml
The AndroidManifest looks like
<!-- set up an own permission to secure our C2DM mesages -->
<permission android:name="your.namespace.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!-- List of permission -->
<uses-permission android:name="your.namespace.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application ..>
<!-- Your implementation of the class C2DMReceiver, base class is Googles C2DMBaseReceiver -->
<service android:name=".C2DMReceiver" />
<!-- Googles broadcast receiver, it delegates to your.namespace.C2DMReceiver -->
<receiver
android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="your.namespace" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="your.namespace" />
</intent-filter>
</receiver>
</application>
If you receive on the emulator the error "E/CSE Notifications(401): Registration error ACCOUNT_MISSING", you have to add a Google account to your emulator.
For your second question: it depends what you want to do. When you receive the message and you just want to display a notification so that the user is able to start your app then you don't need a Phonegap plugin. In that case you can solve everything in java.
In case you get to this answer, notice C2DM is absolete and now you have to use GCM.
Moreover there is an official PhoneGap plugin supporting notification for both Android and iPhone. Check out the PushPlugin at https://github.com/phonegap-build/PushPlugin

Categories

Resources