I am trying to implement SMS Retriever API, but I am unable to find classes like SmsRetrieverClient. I'm not able to import them.
Refer to the following sample code:
SmsRetrieverClient client = SmsRetriever.getClient(context);
Task<Void> task = client.startSmsRetriever();
task.addOnSuccessListener(new OnSuccessListener<Void>() {});
I have added following dependency, after which I am able to refer the classes:
compile 'com.google.android.gms:play-services:11.0.2'
But as this include all service API, I want to know the dependency specific to SMS Retriever API
I have referred to this doc for all dependency and added following, but it did not work.
com.google.android.gms:play-services-auth:11.0.2
com.google.android.gms:play-services-identity:11.0.2
Also, is it necessary to have 11.x.x versions?
Try adding the following dependency:
implementation "com.google.android.gms:play-services-auth-api-phone:$playServicesVersion"
replace $playServicesVersion with the play services version you are using.
Do you have error logs that may show the problem? For the meantime, try the old version first from the SMS Retriever document:
The SMS Retriever API is available only on Android devices with Play
services version 10.2 and newer.
Check this one if the old version imports SmsRetrieverClient successfully.
Related
I have the following setup in my grade files:
project:
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
app:
implementation platform('com.google.firebase:firebase-bom:29.0.0')
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
After the users logs in, I'm doing
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(task -> {
String refreshToken = task.getResult();
....
}
which is fine for most users, but for some (not only a few) get errors like FIS_AUTH_ERROR, MISSING_INSTANCEID_SERVICE, SERVICE_NOT_AVAILABLE.
I guess (!), MISSING_INSTANCEID_SERVICE is no Google API on the device, SERVICE_NOT_AVAILABLE missing network (?) but I'm not sure at all. And I have absolutely no clue about the FIS_AUTH_ERROR. Is there some documentation about this?
MISSING_INSTANCEID_SERVICE
Tokens can't be generated.
SERVICE_NOT_AVAILABLE
The device cannot read the response, or there was a server error.
FIS_AUTH_ERROR
you need to check the documentation get token and get id methods had changed
I think it has to do with firebase dependencies versions mismatch. Try to import the BoM for the Firebase platform. By using BoM your app will always use compatible versions of the Firebase Android libraries.
dependencies {
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:30.0.2')
// .... }
FIS_AUTH_ERROR suggests, that the local installation cannot be authenticated:
Firebase Cloud Messaging uses Firebase installation IDs to target devices for message delivery.
Source: Manage Firebase installations
It's a little difficult, unless having a device available, which would show this issue - or somehow being able to narrow this down - by hardware vendor, Android version or package version - because "some (not only a few)" is relatively meaningless, from a technical perspective.
It could well be, that the SHA1/SHA265 key fingerprint might have been changed (you should know) and "some (not only a few)" might still haven't updated to the latest version of the APK/AAB package, signed with the new signing key. Crashlytics would show the package version. You could add the old SHA1/SHA265 key fingerprint back in, so that their instances could authenticate again.
I have received email from google:
We recently announced that we’ll be deprecating the install_referrer intent broadcast mechanism. Because one or more of your apps uses this intent to track referrals, we wanted to ensure you make the switch before March 1, 2020. After this date, new versions of the Play Store app will no longer broadcast the install_referrer intent after app installs.
I am not using install_referrer directly, but while browsing merged manifest i discovered that some firebase service named with package name com.google.firebase.measurement use it.
My firebase dependencies updated to latest version.
Should I care about it?
From Firebase support:
This is a great catch. Thanks for bringing this to our attention.
There's no need [to take] action from your end as of now, I've created an
internal request so we could provide an alternative for the
install_referrer intent broadcast before its deprecation. As of now,
we are yet to find out any details or timelines as to when it will be
implemented. You can check our release notes from time to time for any
updates about Firebase features and its services.
Strange that Google's products are not synchronized.
However if you are not using Firebase and your app contains third party libraries that use install_referrer kindly check directly with them.
To find in which library install_referrer included, open merged manifest and search for install_referrer, check the package name of the service in which the install_referrer included.
com.google.firebase:firebase-core:17.2.1 and com.google.firebase:firebase-analytics:17.2.1 add INSTALL_REFERRER to AndroidManifest. Probably need to wait till Firebase team updates these packages to use the new API.
Various SDKs can register a receiver for the install referrer.
For developers who are unsure about which SDK added a receiver to your manifest it's useful to look at the manifest merge blame file.
Typically, in build/ there's a file intermediates/manifest_merge_blame_file/release/manifest-merger-blame-release-report.txt
In that file you'll need to find receivers that have
<action android:name="com.android.vending.INSTALL_REFERRER" />
in it's intent-filter, and the line before it will indicate what the source of that line is in your manifest.
For instance, the relevant lines for one of my apps looks like this:
44 <receiver
44-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:29:9-35:20
45 android:name="com.appbrain.ReferrerReceiver"
45-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:30:13-57
46 android:exported="true" >
46-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:31:13-36
47 <intent-filter>
47-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:32:13-34:29
48 <action android:name="com.android.vending.INSTALL_REFERRER" />
48-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:33:17-79
48-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:33:25-76
49 </intent-filter>
50 </receiver>
This shows that the AppBrain SDK (of which I'm one of the developers) adds a receiver for the install referrer. The following image from our blogpost explaining what exactly changes (https://medium.com/appbrain/the-google-play-referrer-api-and-the-appbrain-sdk-38cfbaa350dc) is clarifying what Google is changing:
After checking the manifest file on my builded apk, i found the install refeer broadcast used by the firebase-measurement-connector module on Firebase Core Analytics so i exclude them :
implementation ('com.google.firebase:firebase-ads:17.2.0')
{
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}
And then recheck again my manifest mereged file by Analyzing APk and the Install refeer broadcast is disappeared.
On other side, if you use track analytics, Google ask to switch to the Install Referrer API https://developer.android.com/google/play/installreferrer/library.html before March 2020
I checked Firebase support agent for this issue. Firebase libraries are using install_referrer, and I got below response from Firebase support agent:
This is a great catch. Thanks for bringing this to our attention. I'm
currently in discussion with our Analytics experts and will get back
within 48 hours, or as soon as I have more information. For now, no
need for any action from your end, wait for the next update from the
Firebase team.
I believe we need to wait Firebase's next release. And Firebase team updates these packages to use the new API.
If you have used this API in your code by yourself, then you need to change it immediately as you are not depending on firebase or any other third party library provider.
There is one article on Android developer blog about this
https://android-developers.googleblog.com/2019/11/still-using-installbroadcast-switch-to.html
Also in this article they mention old implementation of install_referrer intent broadcast mechanism and provide complete information. So we can find this in our existing code.
https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-campaigns
INSTALL_REFERRER comes not only with Firebase but also withADMOB. I can confirm that Admob v3.18.3 has this permission but it is no longer coming in Admob v4.2.1. I have not tested other versions but i have heard that some previous versions like 4.2.0 & 4.1.0 also not carrying this permission.
But the question here is whether we need to remove the permission or we need to make sure that if our app is using Play Install Referrer Library then the INSTALL_REFERRER must be included. Because action required is not to remove it but migrate to it.
I have already integrated SMS Retriever Api and its working fine on devices with latest play services (checked with play services version 16.x.x and above)
The issue here is if I am running it on a device with Play Services 11.9.xx then the SMS Retriever client doesn't get registered also no error is thrown it simply skips over and doesn't work !!
But As per the docs -
Prerequisites -
The SMS Retriever API is available only on Android devices with Play
services version 10.2 and newer.
So it should have worked with my device as play services was greater than 10.2
Please suggest what I am doing wrong !!
The code used to register client :
fun setRetrieveSmsTaskListener(context: Context) {
val client = SmsRetriever.getClient(context)
val task = client.startSmsRetriever()
task.addOnSuccessListener {
LogUtils.debugLog(LOG_TAG, "Sms retriever api task Success")
}
task.addOnFailureListener {
LogUtils.debugLog(LOG_TAG, "Failure Sms retriever api task with exception $it")
}
task.addOnCanceledListener {
LogUtils.debugLog(LOG_TAG, "Canceled Sms retriever api task with exception")
}
}
And the depencies used :
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
Use lower version of play service(like below) and try again
implementation 'com.google.android.gms:play-services-auth-api-phone:11.0.4'
Or update the google play service version on device if you are using latest version of dependencies.
Play services API suggests that there is something called Instance ID
However, after including the following in Android Studio, I am unable to import InstanceID class
compile "com.google.android.gms:play-services-identity:${googlePlayServicesVersion}"
compile "com.google.android.gms:play-services-auth:${googlePlayServicesVersion}"
Per this SO Post, InstanceID class should work if I include the identity play services library.
Following conversion of google cloud messaging to firebase cloud messaging, I believe, it must have been replaced by Firebase Instance ID as mentioned in the red message here.
Now I am not sure if using Firebase ID should have indeed "replaced" Instance ID.
Or, maybe I am missing some library which includes InstanceID?
Yap,
I had the issue, and finally I realize that InstanceID class is a part of 'com.google.android.gms:play-services-iid' library , so you just have to add this line in your gradle build file:
compile "com.google.android.gms:play-services-iid:${googlePlayServicesVersion}"
Unless this works for me :) ...
I'm just started experimenting with Beacons and Android apps, I installed Estimote SDK by adding compile 'com.estimote:sdk:1.0.3#aar' to the dependencies of my build.gradle file but i get only com.estimote.coresdk.*
and the com.estimote.mgmtsdk.*, and not the com.estimote.sdk.*, which i suppose is the fully-fledged SDK.
Where am I wrong? How do I get the full SDK? (I have an Estimote Cloud account with -for now- a single Estimote assigned)
EDIT: Actually CoreSDK is the new package inside the Estimote SDK (not the old one, as I thought). So yup, if you get the CoreSDK you're all set.
Installation
Add this line to your build.gradle file:
dependencies {
compile 'com.estimote:sdk:1.0.11'
}
Initializing Estimote SDK
Initialize Estimote SDK in your Application class onCreate() method:
// To get your AppId and AppToken you need to create new application in Estimote Cloud.
EstimoteSDK.initialize(applicationContext, appId, appToken);
// Optional, debug logging.
EstimoteSDK.enableDebugLogging(true);
For more information check the README.md