How to implement AndroidPay auto OTP filling? - android

So I have a verification code that comes through from sms and user has exit app to go copy it into an EditText.
I found out the Android Pay has a method to scan the incoming verification text from your bank and autofill the text with a verification code.
I'd like to replicate this for my own app but I'm not 100% sure how I do this as I'm struggling to search for what I need. What I've found so far is it could be done via a ContentResolver but that might not be the best solution as it could be different on different Android flavours.

You want a broadcast receiver for SMS, which reads an incoming SMS, checks if the number is right and if the format of the SMS is right, and parses the number from it.
Actually if you can do that there's no need to autofill- just send the request to the correct API for verification directly, so they don't even have to press send.

Android has this built in since play services 10.2.x.
It works only if you include an app specific hash in the SMS message body, which android uses to determine which app to alert that a new message just came in.
When an SMS message with that exact hash is received, android will fire up a broadcastreceiver that youregister in the manifest with a special intent filter:
<receiver android:name=".MySMSBroadcastReceiver" android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED"/>
</intent-filter>
</receiver>
How it works in more detail and what code is required etc, you can check here on the developer's blog or here in the official guides.
Note that this won't work if you don't have access to the system that sends out the SMS, meaning you can't add the hash to the message.

Related

Create Message voice action for non en-us locales

I would like to know which are my posibilities as a developer to implements a send message voice action, in a messaging app (like a custom Telegram app), for spanish users. I want to implement the send new message action, I does not interested in replying to received messages (this is already implemented).
This is an example of I want to implements:
Create Message action
The user tells an utterance like "I would like to send a message with whatsapp".
A widget asks for a contact to send the message (if the user did not especificated one).
The app sends the message.
This is the same working example for spanish language: Create Message action (spanish)
I already know that there are built-in intents but the CREATE_MESSAGE built-in intent is only available for en-us locale. I also checked the custom intents but there are also only availables for en-us locale as I know. Which more options do I have?
PD: My final goal is to make the app compatible for Android Auto so I'm making it compatible with google assistant first.
Thanks in advance.
As you note, the actions.intent.CREATE_MESSAGE BII is only available in en-US right now. This is probably the best one, since it provides getting and sending a message without any additional work.
You may want to see if actions.intent.OPEN_APP_FEATURE will work for your needs. It has the downside that it does not have the fields available in CREATE_MESSAGE, but it might be a useful way to open the app.
However...
If you're planning on targeting Android Auto, that platform is even more restricted. If you're building an Android Auto app, you are limited to use only the actions.intent.GET_PARKING_FACILITY or actions.intent.GET_CHARGING_STATIONS BIIs. If you are willing to have it return a widget, you get a little more flexibility in what BIIs it accepts, but these don't let you send a message or open the app (even in en-US).

Use of SMS permission groups exception for Anti-Smishing

I try to develop anti-smishing solution, which listen in background and analyze new SMS.
If I'm not default SMS app, I can only read the SMS.
I found information about some exceptions in use of SMS permission group for Anti-Phishing, where I have access not only to read, but also to write.
How does it work? For now I'm not able to write or edit any SMS in Android Studio. When Google accepts my request/form I will have some extra code for exception or something like it?
https://support.google.com/googleplay/android-developer/answer/10208820?hl=en&ref_topic=2364761#zippy=%2Cwyj%C4%85tki

Android - Google Assistant not providing the number for CREATE_CALL BII

I am trying to integrate CREATE_CALL BII I can trigger my app using the voice command “Call <CONTACT_NAME> on <APP_NAME>” but I am facing a problem that the BII is only sending me the CONTACT_NAME but not the PHONE_NUMBER even though that contact is in android native Addressbook.
Following is my action:
<action intentName="actions.intent.CREATE_CALL">
<fulfillment urlTemplate="https://fit-actions.firebaseapp.com/call{?callFormat,name,telephone}">
<parameter-mapping urlParameter="callFormat" intentParameter="call.callFormat"/>
<parameter-mapping urlParameter="name" intentParameter="call.participant.name" />
<parameter-mapping urlParameter="telephone" intentParameter="call.participant.telephone" />
</fulfillment>
</action>
Action is working perfectly with
App Actions Test Tool
I am following https://developers.google.com/assistant/app/reference/built-in-intents/communications/create-call, even though I copied the same code from that link to my sample to make it work but I am getting the same result, the only name is there in my deep link but no phone number is there.
What I want to achieve the way Google Duo is doing shown in the following gif
App Actions doesn't know how to look up additional information about the contact in the query. The phone number is only provided if it was spoken in the request.
If you need a phone number for the contact, you will have to write code to query your address book using the name provided in the user's query. You might find that the user's query is not specific enough to locate one specific contact, and in that case, you will have to provide a UI to disambiguate the request (e.g. if there are two people named "Lee", the user will need to be able to choose which one they meant).

2 GCM registrationId for same android application

I have 2 GCM BroadcastReceivers in my application (One for an android library integrated in my application and one for my own application).
Both of them are registered in the manifest and have the same category (Which is my application package name).
Both have registration with register() function and both receives different valid registrationId's (because the senderId for both are different).
My problem is that I have everything work fine (Both Recievers get the push notification) but after a couple of hours when trying to send a push from Server I encounter "NotRegistered" issue in my server (android library regId) and registrationId seems invalid all of a sudden.
So my question is can I have 2 different GCM "Mechanism" in the same application with different senderId without a collision or some sort on GCM Servers ?
In that case, It will never create collision as both will work as different applications (Both is having different SENDER_ID).
Check the following notes :
1) Make sure that you have added different category name (With INTENT-FILTER) for both library and application :
<receiver
android:name=".xxxxx"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.xxxx" />
</intent-filter>
</receiver>
2) Sometimes the Reg Id is getting changed automatically so try to save the previous one and check each time if it is same, if not then you have to update new one with your server.
UPDATE :
When you send a message, you specify a registration ID, which is implicitly linked to the package name of the app and device where it was generated. Only the app which requested the registration ID will receive your message. So it will conflict because you are using the same library (Same Package name) with different applications.
So your solution might be to do all stuff related to GCM in SingleToneClass with library. In which you will pass your application package name to register with GCM. So whenever you will use your library with different applications, It will refer different package name and SENDER_ID will be the same but it will not cause problem as package name will be changed.

Fiksu SDK Integration

I am trying to implement Fiksu SDK for Android and iOS.
I am able to add code to track registration and purchase :
FiksuTrackingManager.uploadRegistration(Context, FiksuTrackingManager.RegistrationEvent.EVENT1);
FiksuTrackingManager.uploadPurchase(Context, FiksuTrackingManager.PurchaseEvent.EVENT1, 0, "USD");
In iOS i am able to get the logs in the console, but in android i am only getting logs which event is called.How can i check the logs in Android ?
Also how to track the app events in Fiksu dashboard ?
They have also mentioned to add client id , from where will i get the client id ?
if any one has implemented it please guide me how to proceed ?
this might be too late but it may help someone that comes across this post.
I just had to integrate the Fiksu SDK for android for a client and face similar issues when testing.
How can i check the logs in Android ?
If the SDK has been properly installed you should be able to see some logs like below which means the events have been succesfully sent to their server.
11-25 10:04:31.010 21588-23132/ D/FiksuTracking? Event: Resume
11-25 10:04:32.320 21588-23132/ D/FiksuTracking? Successfully uploaded tracking information.
11-25 10:05:40.500 21588-23383/ D/FiksuTracking? Event: Purchase
11-25 10:05:42.180 21588-23383/ D/FiksuTracking? Successfully uploaded tracking information.
how to track the app events in Fiksu dashboard ?
This part is quite annoying as they don't have a way to create Apps in the dashboard and link them to your android app so you can see your events coming through. Instead you have to actually perform the test and send them an email for someone from Fiksu to check their servers and track your events.
These are the test steps as per their documentation:
Download and install your application on an Android device and perform your tests.
Fill a form they have and send it via email to their support team.
Someone will get back to you confirming if they have received your events.
They have also mentioned to add client id , from where will i get the client id ?
The clientId is just an identifier for your users within your app. In other words you can set that to whatever you want (e.i. email address). The suggestion is to set this after a user has registered or logged in in your app.
FiksuTrackingManager.setClientId(Context, "XXX");
Based on their documentation: "Where XXX would be the ID you want to send and can be any alphanumeric string up to 64 characters long. All events sent after this call is made would send the Client ID that has been set. If you call setClientID again it will overwrite whatever was there before. However the first Client ID sent with an event will be the Client ID that is in the export on the Fiksu Client Dashboard and it will not get updated."
if any one has implemented it please guide me how to proceed ?
So to sum up below are the steps to integrate the Fiksu SDK for android.
Downlaod the SDK.
Add the SDK jar to your project.
Set the isntall receiver (Only if you want to track app installs). NOTE that they expect to be the only receiver in the AndroidManifest.xml file. If you are using other third party SDKs to track the same you either:
Use fiksu to forward the intent:
<receiver android:name="com.fiksu.asotracking.InstallTracking"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
<!-- Forward to other receivers -->
<meta-data android:name="forward.1"
android:value="com.google.android.apps.analytics.AnalyticsReceiver" />
<meta-data android:name="forward.2" android:value="com.mypackage.thirdparty.MdotmReceiver" />
</receiver>
Or set the below flag in your AndroidManifest and have another install receiver forward it to the fiksu SDK.
<meta-data android:name="FiksuDisableReceiverCheck" android:value="true" />
Set the permissions in your AndroidManifest.
android.permission.INTERNET
android.permission.READ_PHONE_STATE
Initialize the SDK. Normally on your Application onCreate() method.
FiksuTrackingManager.initialize(this);
Setting up Google Play Services on your project.

Categories

Resources