AWS amazon android firebase push notification - android

I have an issue with implementing Android AWS Amazon push notification using firebase, in Amazon sample, it shows you to add this line of code
link
AWSMobileClient.defaultMobileClient().getPinpointManager().getNotificationClient().registerGCMDeviceToken(refreshedToken);
But once you add it to the project AWSMobileClient class not initialized so I have added these SDK's
compile 'com.amazonaws:aws-android-sdk-core:2.4.5'
compile 'com.amazonaws:aws-android-sdk-cognito:2.4.5'
compile 'com.amazonaws:aws-android-sdk-pinpoint:2.4.5'
compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.4.5'
But they didn't initialize, after searching I found that you have to add the sample so I added it
Sample classes
but the classes didn't initialize.
So is there any straightforward example to Initializing this thank you.

Hopefully this helps. You'll need to fill in:
IDENTITY_POOL_ID
APP_ID
Adjust Regions.US_EAST_1 to whichever region you are using.
Code:
CognitoCachingCredentialsProvider cognitoCachingCredentialsProvider = new CognitoCachingCredentialsProvider(context,"IDENTITY_POOL_ID",Regions.US_EAST_1);
PinpointConfiguration config = new PinpointConfiguration(context, "APP_ID", Regions.US_EAST_1, cognitoCachingCredentialsProvider);
PinpointManager pinpointManager = new PinpointManager(config);
pinpointManager.getNotificationClient().registerGCMDeviceToken(refreshedToken);

Related

How integrate the new conscrypt library to Android and use it by default

In android, if i get (SSLSocketFactory) SSLSocketFactory.getDefault() i get the inner socket factory with this class com.android.org.conscrypt.OpenSSLSocketFactoryImpl.
After adding this dependency
dependencies {
implementation 'org.conscrypt:conscrypt-android:2.2.1'
}
I want to get (SSLSocketFactory) SSLSocketFactory.getDefault() the factory from new lib (org.conscrypt.OpenSSLSocketFactoryImpl), but still geting the inner com.android.org.conscrypt.OpenSSLSocketFactoryImpl.
What is the integration algorithm for the new SocketFactory ?
You have to set the Conscrypt provider as first security provider, otherwise it will not be loaded:
Security.insertProviderAt(Conscrypt.newProvider(), 1);
Setting it as first provider will prevent Android from using the default one.

How to implement custom AWSCredentialsProvider?

I need to replace CognitoCachingCredentialsProvider with custom AWSCredentialsProvider, to add custom headers with every IoT request, is this possible and how?
My current code snippet:
CognitoCachingCredentialsProvider credentialsProvider;
AWSIotDataClient iotDataClient = new AWSIotDataClient(credentialsProvider); iotDataClient.setEndpoint(AWSConstants.CUSTOMER_SPECIFIC_ENDPOINT);
GetThingShadowRequest request = new GetThingShadowRequest()
.withThingName(AWSConstants.TEMP_THING_NAME);
GetThingShadowResult result = iotDataClient.getThingShadow(request);
Now what I want to do is to replace CognitoCachingCredentialsProvider with custom CredentialsProvider to add custom headers with every iot request.
My Team just contacted aws support and the above question is not applicable.
Edit: aws team is working on that right now, feature will be available soon

cannot resolve AutocompleteFilter.create

I am trying to use this code to filter autocomplete results from google places:
List<Integer> filters = new ArrayList<Integer>();
filters.add(AutocompleteFilter.TYPE_FILTER_ADDRESS);
filters.add(AutocompleteFilter.TYPE_FILTER_CITIES);
mAutocompleteFilter = AutocompleteFilter.create(filters);
but it cannot resolve method AutocompleteFilter.create.
build.gradle:
compile "com.google.android.gms:play-services-maps:11.4.2"
compile "com.google.android.gms:play-services-auth:11.4.2"
compile "com.google.android.gms:play-services-location:11.4.2"
compile "com.google.android.gms:play-services-places:11.4.2"
Is it because of version 11.4.2? I don't want to downgrade. Is there any other alternative to use multiple integers in this AutocompleteFilter?
There is no create method instead use AutocompleteFilter.Builder.
From Docs
Use AutocompleteFilter.Builder to create a new AutocompleteFilter.
mAutocompleteFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();
Seems, there are no possibilities to apply several filters via AutocompleteFilter, but you can use PlaceSearch on each separate place type instead of it:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={LAT},{LON}&radius={RADIUS}&type={PLACE_TYPE, e.g. restaurant}&keyword=cruise&key={YOUR_API_KEY}

Android switch from Parse to Parse Server crashes

I'm migrating my Android and iOS app from Parse.com to Parse Server. First I'm doing this migration with a test app to be sure everything is ok.
With iOS there has been no problem but with Android the updated app crashes each time the user enters in the app.
This is the Android code updated:
public static void initParse(Application app) {
ctxt = app.getApplicationContext();
Parse.enableLocalDatastore(app);
// Old version
//Parse.initialize(app, "<my app id>", "<my client key>");
// New version
Parse.initialize(new Parse.Configuration.Builder(ctxt)
.applicationId("<my app id>")
.clientKey(null)
.server("https://<my new server>/parse/")
.build()
);
ParseUser.enableRevocableSessionInBackground();
}
The crash returns a "com.parse.ParseException: java.lang.IllegalStateException: unable to encode an association with an unsaved ParseObject", and taking into account what I've read in Stackoverflow, this is because ParseUser.getCurrentUser() returns null (despite the user is logged in) and Parse methods fail.
In fact, if I take this same code, uncomment the old version of Parse.initialize, comment the new version of Parse.initialize, compile and launch the app, this is launched without problems and the user can use it properly.
But again, if I comment the old version of Parse.initialize, uncomment the new version of Parse.initialize, compile and launch the app, this crashes inmediately because ParseUser.getCurrentUser() returns null and Parse methods fail.
What am I missing here? Should I force my users to login again? This seems to me a bad UX, and anyway, in iOS I have no problems with the new version, what is the difference between both platforms?
EDIT 1:
Following Robert Rowntree advice I've changed the initialization to this:
public static void initParse(Application app) {
ctxt = app.getApplicationContext();
Parse.enableLocalDatastore(app);
// Old version
//Parse.initialize(app, "<my app id>", "<my client key>");
// New version
Parse.initialize(new Parse.Configuration.Builder(ctxt)
.applicationId("<my app id>")
.clientKey("<my client key>")
.server("https://<my new server>/parse/")
.build()
);
//Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
ParseUser.enableRevocableSessionInBackground();
}
Besides this I've checked that my Parse version is the last available, I have this in my gradle file:
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
And the result is the same, the app crashes with "com.parse.ParseException: java.lang.IllegalStateException: unable to encode an association with an unsaved ParseObject" the first call I make to Parse.
Besides this, the unique log I can see related to parse is one related to GCM token, nothing else.
EDIT 2:
I've tried another thing, uninstall the app with the old initialization and install it with the new initialization and as I guessed the new version is now working.
But, of course this is not a solution to me, I can not tell my users to uninstall the app ans install it again.
But this is a hint: there is no problem with the new initialization but with how the old Parse "reacts" when opening the app with the new Parse Server, there must be any inconsistency in getCurrentUser or something like that.
Can you try initializing like this:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("APP_ID")
.clientKey("CLIENT_KEY")
.server("https://SERVER_URL/parse/") // The trailing slash is important.
.enableLocalDataStore()
.build()
);
notice the
.enableLocalDataStore()
is in the initilization. Remove this:
Parse.enableLocalDatastore(app);

Firebase Analytics even show up in log but not on firebase console

I am trying to integrate Firebase RemoteConfig and Analytics with my Android application. Remote configuration part is working but Analytics part is not working. Here is my build.gradle
// Firebase configuration
compile group:'com.google.firebase', name:'firebase-core', version: '9.4.0'
compile group:'com.google.firebase', name:'firebase-config', version: '9.4.0'
// Firebase analytics
compile 'com.google.android.gms:play-services-analytics:9.4.0'
Here is my Activity code.
FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(this);
firebaseAnalytics.setUserId("5107611364");
firebaseAnalytics.setUserProperty("custom_user_property", "custom_user_proerty_value");
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "SomeID");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "SomeIDName");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "IdType");
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
I am trying to publish customer property as well as the event but both of them are not working. I have enabled adb logging and I can see that custom event and property are published. These do not appear on the Firebase Analytics console even after 24hrs. I don't know what is wrong.
#Rakesh - you are looking in the wrong location. You are supplying customID feilds, in your example you are supplying CONTENT_TYPE : IdType. You don't need a minimum of 10 users to see the data...if you only have 1 user that data will appear within 24 hours of that user using your app.
I will say this, initially finding your own custom IDs is not very straight forward...it took me a while to find it too.
The place to find that custom reported info is: Anaylytics - Events - once on this page, click on the actual CONTENT_TYPE you are wishing to track, in your example above, it would be idType
Then on the Content graph you will see your customIDs (ie: someID)...click on someID. In my case (and in my screenshots) my equivelant someIDs are "field, button & select"
and then you will see all the data related to the values (someIDName) you passed into someID.
Now, if idType is not appearing for you then that may because Firebase isn't allowing you to create your own CONTENT_TYPE, I am not certain if you can do that as I have not tried...and in that case you would need to use a predefined CONTENT_TYPE. I am not using a custom idType, I am using CONTENT_TYPE : select_content.

Categories

Resources