Hi I want to implement google app indexing for android. But the documentation is confusing. Months ago I implemented local autocompletion using the following guide:
https://codelabs.developers.google.com/codelabs/app-indexing/#0
Now I want to enable google search feature, the doc claims that google systems will crawl my manifest file and based on intent-filters will do the indexing, here is a fragment of that doc:
https://developers.google.com/app-indexing/android/publish#add-app-indexing-api-calls
So I'm confused, what is the difference between this two links? Should I have both of them in my code or the previous link is just the old version of doing things ?
There is no difference in both the guides you mentioned. Except that in the 1st guide, you are capturing the result of AppIndex.AppIndexApi.start and writing it to log. And in the 2nd one, you are not.
Compare the onStart() method in both of them. You are first connecting to GoogleApi client. Then calling the start method of AppIndexApi.
Related
I'm just getting started with using the Google Drive REST API in an Android app. (I can't use the Google Drive API for Android because the app needs to share files, and perhaps a few other things, that GDAA doesn't support.) I'm stuck on a couple of points.
The first has to do with OAuth2.0 credentials. I went through the Android quick start example and it works fine. I set up a project on my Google developer console and generated an OAuth2.0 client ID and secret and also downloaded the JSON credentials file. However, the quick start example doesn't show how to plug any of this into the app. The only thing I found in the docs that seems relevant is GoogleClientSecrets, but I don't see anything about how to use that in an Android app. (The Java quick start example uses this, but it's not integrated with Android's account manager and doesn't seem right for an Android app.) When I run the Android version of the quick start app, no activity shows up on my developer console, which suggests to me that the app is running in some sort of anonymous mode. As I understand it, that would limit the app to a very low daily quota of transactions.
Second, I noticed that the GDAA and the REST API for JavaScript both have nice file picker APIs. I couldn't find anything similar in the Java/Android API.
So here are my specific questions:
How do I use my app's OAuth2.0 credentials from the developer console in a REST API for Android Java app? I feel like I'm just missing something obvious.
Is there a file picker API for the Google Rest API for Android?
After stepping through the library as I executed the Quickstart example (a painful process, as there is no source code), I discovered the answer. It turns out that you need to specify the client ID in the manifest. Specifically, you needs the following under the <application> tag:
<meta-data
android:name="com.google.app.id"
android:value="app ID from your API console"/>
Once this entry is in the manifest, then when the app uses the Google Drive REST API to interact with Google's servers, the transaction is correctly logged as traffic in your app's console. Without this entry, the app seemed to work in my testing, but no traffic was logged. I seem to recall (from an old Google I/O video) that such "anonymous" apps still work, but have a very low usage quota (something like 10 or 100 queries/day).
For those who are curious, I found this key in the class com.google.android.gms.common.internal.zzz, found in the play-services-basement-10.2.0 library.
Save the client_id.json file downloaded from the Google API console into into your app's src/main/res directory.
I was stuck exactly the same, but after I built my app with the file included the Google API started working.
How do I use my app's OAuth2.0 credentials from the developer console in a REST API
The pages around https://developers.google.com/android/guides/api-client give you all that you need to know. In particular, note the Java Quickstart you were using is for generic Java. The way Google Play Services on Android manage credentials and accounts is very Android-specific.
Is there a file picker API for the Google Rest API for Android?
Not that I know of, but depending on your use case, you might be able to use the GDAA picker. Ultimately, both GDAA and the Java REST API are layers above your Drive storage.
Background
Google allows to perform app-invites and also track how well they improve your app installations:
https://www.youtube.com/watch?v=UfdCNYXMC9M
The problem
I made a simple app invite, and it seems people do use it, using this code:
public static Intent getAppInviteIntent(Context context) {
return new AppInviteInvitation.IntentBuilder(title,appName).setCustomImage(imageUri).setMessage(message).setCallToActionText(download).build();
}
startActivityForResult(getAppInviteIntent(this), GOOGLE_APP_INVITES_REQUEST_CODE);
This works, but in the Analytics webpage, I can't find a way to show the statistics of the app-invite, and that's even though they say it's automatic (here). Sadly, even what I've found seem quite old and they use deprecated functions.
What I've tried
I thought that maybe it's not quite automatic (because the tutorial has some extra code for the receiver part too, here), and that we might need to add some code, as this docs say :
When the user accepts an invitation and installs the app, getInvitation(GoogleApiClient, Activity, boolean) will update the invitation state to installed and return the invitation data in an intent accessed from AppInviteInvitationResult using getInvitationIntent()
Looking at Google's sample (here), I've noticed they created 2 activities. One is the main activity, which does have a call to "getInvitation" , and another is called "DeepLinkActivity" , and handles deep links (which is probably for extra data, like coupons).
I've also found some stackOverflow questions about the tracking (like here), but all I see is that people didn't succeed tracking yet.
The questions
What is the minimal code needed in order to track the invitations and how well they work, as shown on the video? What should be configured in Analytics page itself? I don't use deep linking currently, so I don't want to use it.
It seems that Google moved the app-invites feature to "firebase" gradle repositories. Is it a must-have? What are the advantages? We currently use the previous ones ("com.google.android.gms:play-services-appinvite:..." ). The dashboard of FireBase doesn't seem to include as much UI for analytics as Google Analytics. Not to mention of app-invites.
If the answer to #1 is that I need to use "getInvitationIntent", does it have to be on the main activity of the app ? Does it have to be in an activity at all (maybe broadcastReceiver?) ?
It seems it's possible to also invite to IOS too ( as shown here and here, using "setOtherPlatformsTargetApplication"). Is this correct? How does it work? What happens when an IOS user clicks the link? What should be put into the parameter of "clientId" and where do I get it from ?
Does G+ have app-invites? If so, does it also have analytics?
Great questions. I'll do my best to answer everything. Please ask if you need clarification.
Analytics tracking requires a tracking Id that you'll need to set using setGoogleAnalyticsTrackingId(String trackingId), which I don't see in your example. This tracking Id is then handed to the downstream events that record analytics tracking events for you:
When invitations are send (both email and sms).
When the invited user accepts the invitation by clicking on the invitation link or button.
When the developer calls getInvitation()
When the developer calls convertInvitation()
So, to answer your specific questions, here goes:
Just add your tracking ID to the builder as described above, and all the tracking events will be reported. No need for a deeplink, that's optional on invites.
Yes, appinvites api is copied to firebase while retaining the original. For now they are exactly the same. Future improvements will be in firebase, so migrate when you have time.
getInvitationIntent() is called on the result returned in the callback from getInvitation(), so the callback should be within an activity. Also, since you'll only expect an invitation immediately after launch, you really only need to check in the main activity and any activity that would be launched from intent filters that trigger on the deeplink. Sounds like you don't use deeplinks, so only the main activity. Generally you should call getInvitation() from all activities that may be directly launched from an invitation, this is how you determine if your app is launched from an invitation.
Yes, invites can go cross-platform in both directions, iOS -> android, and android -> iOS. You need to define both apps in the same project in console.developers.google.com, which is necessary to associate them. If there is more than one iOS app in the project, that api call is necessary to disambiguate the iOS app that is paired with the android app. The ClientID parameter is generated in the console when you create the OAuth Client Id using the pulldown menu from credentials section.
There isn't any separate G+ invites.
Answers:
The Firebase Dynamic Links on Android documentation explains how to view the analytics data shown directly in the Firebase console. The critical step is to follow the Firebase setup instructions, most importantly:
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
The Firebase analytics integration has been streamlined from the legacy integration that required a tracking Id. Now with Firebase only setup and a call to getInvitation() are needed. No additional code or tracking ids required. Remember it takes up to 24 hours to see the results in the console. However, you can see the messages being sent immediately which is a great indication that it's working. Just enable verbose logging as described in Analytics Log Events documentation.
The Firebase and android developer documentation for appinvites are identical.
Yes, you must call getInvitation() to get analytics tracking, and do the setup as described above.
The iOS and Android equivalence apps should be in the same project. Just move them to a single project in the Firebase console. You can just remove one from it's existing project and add it to the other to make a combined project. The change should be reflected instantly.
I've done a bunch of app-indexing work on our mobile app from tutorial here , and it seems to work locally, when I typed something in Google Now launcher box, the historical results show, clicking on it brings to our app.
However, we track our weburl we submitted when doing app-indexing for the past month, no records of googlebot shown.
So how do I check whether I did things correctly or the bot really working?
Thanks
There are a couple things you can do:
Test whether your deep links are correct. You can do that with the Deep Link Testing tool, see this doc for information on that.
You can measure your deep links performance now, see here how to implement this, but basically the referrer information would be passed on in the Intent.EXTRA_REFERRER intent for you to extract referrer info.
You can use Search Console both to render your app, and to track its performance. For this you would have to add the app to Search Console (Add Property, then add the android app package name: android-app://com.xyz)
I'm building an app on android that has the features of Log-in with facebook and Log-in with Google. Assuming the user chooses to login with google, I would like to ask for permission and collect basic information such as name,age,sex,location,email from his profile and save it on my server's database.
Here is the problem: Which api should I actually use to grab these info? I don't think google+ api would be a proper choice since not every google user has one. After checking Google-api-java-client documentation, I still cant find anything useful.
There seem to be no library for this basic operation.
The only thing that seems relevant is Google Apps Profile API but
1. it's outdated.
2. Its not free.
I'm too confused and I hope someone can guide me through this nightmare.
Edit: found some new relevant info but I'm still hoping to find an official java library for this:
https://oauthssodemo.appspot.com/step/1
Found what I was looking for: http://javadoc.google-api-java-client.googlecode.com/hg-history/c35433d3077dc4eb89dccb25618dc70dbd375d65/apis/oauth2/v2/com/google/api/services/oauth2/model/Userinfo.html
I'm trying to integrate google analytics into an android app using the steps here:
http://code.google.com/mobile/analytics/docs/android/
Everything (i.e. screen views, events) is working except for the campaign/referral tracking. Is it enough to update the manifest.xml file? or do I also have to add an onReceive() method?
In the doc, the statement "Only one BroadcastReceiver class can be specified per application" is confusing me. I'm not sure if that means I have to implement one or is just a warning about potential conflicts if I already have one implemented.
New to Android, hopefully this is easy to solve... (
com.google.android.apps.analytics.AnalyticsReceiver is implemented already.
The statement in the docs means that if you want to use Analytics and AdMob referral tracking in one application you need to implement it yourself.
Also keep in mind that it doesn't work in realtime so it may take a day or two until some data shows up.