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
Related
How can I implement play store in-app update with my react-native app, which is already live on play store?
I have already implemented code push and also internal version check via API calls to force the user to update the app.
With Codepush: code push only works for javascript changes. However, there are many scenarios where we will need the whole app to be updated when there is a native code change.
With API check: We need to watch when the update is getting live, and update the version number kept in the backend to force the user to update the app.
Though both these solutions are kind of patchy, I would like to implement the elegant approach of the play-store in-app update, but couldn't find a clue on how to get it done.
I did not find any react-native package for this, so I had to implement it for my self.
You can check the complete tutorial here and below downloadable files here.
But in short, here is what you need to do.
Open android folder in your react-native project with Android Studio and add implementation 'com.google.android.play:core:1.7.3' at the end of dependencies section of the build.gradle(app) file. Like below,
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
.......
implementation 'com.google.android.play:core:1.7.3' // add it at the end
}
Cick sync after adding the dependency.
Download InAppUpdateModule.java and InAppUpdatePackage.java files and place in them in the same directory of MainActivity.java(android/app/src/main/java/<package>/)
Change the package names in both InAppUpdateModule.java and InAppUpdatePackage.java to your project package name.
Now Open MainApplication.java and add our InAppUpdatePackage into getPackages method like below,
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new InAppUpdatePackage());
return packages;
}
Download InAppUpdate.js and place it into your react-native project.
Import the InAppUpdate.js in any js file, wherever you want to use. And use it like below.
componentDidMount () {
InAppUpdate.checkUpdate() // this is how you check for update
}
That's it.
You can download all the files from here
There's a fairly new package that does that: sp-react-native-in-app-updates.
It also handles the iOS case by prompting the user with a native alert that redirects to the App Store.
One more option (Better than the APi check):
Check the latest version from play store and act accordingly, with https://github.com/kimxogus/react-native-version-check
VersionCheck.needUpdate()
.then(async res => {
console.log(res.isNeeded); // true
if (res.isNeeded) {
Linking.openURL(await VersionCheck.getStoreUrl()); // open store if update is needed.
}
});
You can use sp-react-native-in-app-updates library for inapp update.
npm i sp-react-native-in-app-updates
This is a react-native native module that works on both iOS and Android, and checks the stores (play/app) for a new version of your app and can prompt your user for an update.
It uses embedded in-app-updates via Play-Core on Android (to check & download google play patches natively from within the app), and react-native-siren on iOS (to check & navigate the user to the AppStore).
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 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.
I have to integrate the flurry ad in my android application. Can anybody provide the steps to integrate the flurry ad. I have gone through official sdk for flurry but not get any idea. I have followed the link android: Flurry Ads Banner taking Full screen
I have used the code not get any results
FlurryAgent.onStartSession(this, getString(R.string.flurry_api_key));
FlurryAds.fetchAd(this, "ANDROID_BANNER_TOP", mBanner,
FlurryAdSize.BANNER_TOP);
Prerequisites
Flurry Analytics requires a minimum Android API level 10.
Flurry Analytics uses the Android Advertising ID provided by Google Play Services and will check for and respect the user’s ad tracking preference.
Get your API Keys
Start by creating an app. Once you create the app, you’ll receive a Flurry API Key, which you’ll need when using the SDK.
Download the Flurry Android SDK
There are currently two ways of getting the Flurry Android SDK into your application:
Install via jCenter (Recommended):
The Flurry SDK is available via jCenter. You can add it to your application by including the following in your build.gradle file:
// In your top level Gradle config file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
// In your main app's Gradle config file:
dependencies {
compile 'com.flurry.android:analytics:6.3.1'
/*
* Optional library to help in monetizing your app with ads.
* If you include the ads library, you do not need to include
* the analytics library as it is a transitive dependency.
*/
// compile 'com.flurry.android:ads:6.3.1'
//... other dependencies
}
Download .jar files from Flurry Dev Portal
The downloaded archive should contain these files for use with Flurry Analytics:
FlurryAnalytics_x.y.z.jar: The library containing Flurry’s analytic collection and reporting code (where x.y.x denotes the latest version of Flurry SDK).
FlurryAds_x.y.z.jar: The optional library to incorporate Flurry’s ads into your application (where x.y.x denotes the latest version of Flurry SDK).
ProjectApiKey.txt: This file contains the name of your project and your project’s API key.
FlurryAndroidAnalyticsReadmevx.y.z.pdf: A PDF file with instructions (where x.y.x denotes the latest version of Flurry SDK).
Add the FlurryAnalytics_x.y.z.jar to your classpath¶
Using Android Studio:
If using Android Studio, you do not need to do anything further to include the Flurry SDK in your project, as long as you have installed the SDK through jCenter in your Gradle configuration.
However, if you prefer to use the downloaded .jar files, follow these procedures:
Add FlurryAnalytics-5.x.x.jar to your project’s libs folder.
Navigate to File > Project Structure > Module > Dependencies. Click the ‘+’ button in the bottom of the ‘Project Structure’ popup to add dependencies. Select ‘File dependency’ and add libs/FlurryAnalytics-5.x.x.jar.
Add Google Play Services library. If selectively compiling individual Google Play Service APIs, you should include the Google Analytics API.
Using Eclipse
Add FlurryAnalytics-5.x.x.jar to your project’s libs folder. Right-click on each JAR file and select Build Path > Add to Build Path.
Add the Google Play Service library jar file.
Configure your AndroidManifest.xml
- Have access to the Internet and allow the Flurry SDK to check state of the network connectivity.
- Specify a versionName attribute in the manifest to have data reported under that version name.
- Declare min version of that Android OS that the app supports. Flurry supports Android OS versions 10 and above.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flurry.sample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21" />
<!--required permission-->
<uses-permission android:name="android.permission.INTERNET" />
<!--optional permission - highly recommended-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!--optional permission -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".MyApplication"
android:icon="#drawable/app_icon">
<!--your activities -->
</application>
</manifest>
Add calls to init, onStartSession and onEndSession
Follow these steps, adding these calls:
If you are shipping an app, insert a call to FlurryAgent.init(Context, String) in your Application class, passing it a reference to your application Context and your project’s API key:
//If you are shipping an app, extend the Application class if you are not already doing so:
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
new FlurryAgent.Builder()
.withLogEnabled(false)
.build(this, FLURRY_API_KEY);
}
}
Alternatively, you may call init() just before onStartSession(). It is safe to call init() more than once, provided that you use the same API key throughout the application. You may use any type of Context you wish.
If you are writing an app and the minimum target is Ice Cream Sandwich or above (minSdkVersion is set to API level 14 or greater), session handling is completely automatic, and you may skip steps 3 and 4. If you are instrumenting another type of Context, such as a Service, or your minimum target is Gingerbread, proceed with steps 3 or 4.
Insert a call to FlurryAgent.onStartSession(Context) in the Activity’s onStart() method, passing it a reference to a Context object (such as an Activity or Service). If you are targeting Gingerbread, Flurry recommends using the onStart() method of each Activity in your app, and passing the Activity itself as the Context object. For services (or other Contexts), use the Service or the relevant Context as the Context object. Do not pass in the global Application context.
Insert a call to FlurryAgent.onEndSession(Context) in the Activity’s onStop() method, when a session is complete. If you are targeting Gingerbread, we recommend using the onStop method of each Activity in your app. For services (or other Contexts), ensure that onStop is called in each instrumented Service. Make sure to match up a call to onEndSession for each call of onStartSession, passing in the same Context object that was used to call onStartSession. Do not pass in the global Application context.
As long as there is any Context that has called onStartSession() but not onEndSession(), the session will be continued. Also, if a new Context calls onStartSession() within 10 seconds of the last Context calling onEndSession(), then the session will be resumed, instead of a new session being created. Session length, usage frequency, events and errors will continue to be tracked as part of the same session. This ensures that as a user transitions from one Activity to another in your app that they will not have a separate session tracked for each Activity, but will have a single session that spans many activities. If you want to track Activity usage, Flurry recommends using logEvent(), as described in the Custom Events section.
If you wish to change the window during which a session can be resumed, call FlurryAgent.setContinueSessionMillis(long milliseconds) before the call to FlurryAgent.init().
The Flurry SDK automatically transfers the data captured during the session once the SDK determines the session completed. In case the device is not connected, the data is saved on the device and transferred once the device is connected again. The SDK manages the entire process. Currently, there is no way for the app to schedule the data transfer.
You’re done! That’s all you need to do to begin receiving basic metric
data.
We integrated libGoogleAnalyticsServices.jar in our app and it is working fine. By default it includes 'VERSION_CODE' from BuildConfig.java when sending messages to Google Analytics service. I'd like to include 'VERSION_NAME' instead of 'VERSION_CODE'.
1. Is there a way to get a project for libGoogleAnalyticsServices.jar?
2. Is there a way to configure libGoogleAnalyticsServices class to send version_name instead of version_code?