IOException in mReferrerClient.getInstallReferrer() with HMS Core version 5.0.1.307 - huawei-mobile-services

I want to test my own app before going live after integrating with Huawei install Referrer SDK. I followed all the steps found in codelabs and the documentations and when i install the apk on the device , getInstallReferrer method throws IOException. This is my code. What is it that i am doing wrong ?. how can i get installReferrer info for testing purposes ?
Runnable {
referrerClient = newBuilder(context).setTest(true).build()
referrerClient.startConnection(object : InstallReferrerStateListener {
#SuppressLint("SwitchIntDef")
override fun onInstallReferrerSetupFinished(responseCode: Int) {
when (responseCode) {
InstallReferrerClient.InstallReferrerResponse.OK -> {
// Connection established.
try {
val response: ReferrerDetails = referrerClient.installReferrer
val referrerUrl: String = response.installReferrer
val referrerClickTime: Long = response.referrerClickTimestampSeconds
val appInstallTime: Long = response.installBeginTimestampSeconds
}catch (e : IOException){
Log.i("INSTALL_REFERRER","IOException")
}
catch(e: RemoteException){
Log.i("INSTALL_REFERRER","RemoteException")
}
finally {
referrerClient.endConnection()
}
}
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
Log.i("INSTALL_REFERRER","NOT AVAILABLE")
}
InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE -> {
Log.i("INSTALL_REFERRER","SERVICE UNAVAILABLE")
}
}
}
override fun onInstallReferrerServiceDisconnected() {
Log.i("INSTALL_REFERRER","ReferrerServiceDisconnected")
}
})
}.run()

Please check whether the AIDL interface is added.
Check the screenshot below:
Obtain Install Referrer Information by AIDL
You can call an AIDL API provided by HUAWEI Ads Kit to obtain install referrer information from HUAWEI devices, without integrating any HUAWEI SDK. The install referrer information obtained from a device in either mode (SDK or AIDL) is the same.
Call Process
The Development Procedure is as follows
Create an AIDL file for the IPPSChannelInfoService API and save the file.
Copy the following content to the AIDL file:
package com.huawei.android.hms.ppskit;
/** Important: Do not change the method sequence in the AIDL file. */
interface IPPSChannelInfoService {
String getChannelInfo();
}
Change Build Action to AndroidInterfaceDescription of AIDL file.
Rebuild project.
Create a class to implement Android-native IServiceConnection.
For more details, see docs.
Also, please kindly refer to the demo.
Update:
The package name needs to be specified because setTest(true)
if (this.isTest){
var2 = "com.huawei.pps.hms.test";
}
The empty check on ReferrerDetails can be added.
if (null != referrerDetails && null != mCallback)

Related

I'm using firebase messaging in my flutter app but when I run my project it show Stringtoken=FirebaseInstanceId.getInstance().getToken(senderId, "*");

I'm using firebase messaging in my flutter app but when I run my project it show String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
when I run my application it shows this error in the console:
C:\Users\cerbi\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:166: error: cannot find symbol
String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
What went wrong:
Execution failed for task ':firebase_messaging:compileDebugJavaWithJavac'.
and when I navigate to the specific file stated in the error message here is the code in there
private Task<Map<String, Object>> getToken(Map<String, Object> arguments) {
return Tasks.call(
cachedThreadPool,
() -> {
String senderId =
arguments.get("senderId") != null
? (String) arguments.get("senderId")
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
return new HashMap<String, Object>() {
{
put("token", token);
}
};
});
}
What can I do to resolve this problem, it seems that the existing code is not working anymore
You should use
FirebaseMessaging.getInstance().token
to get token, since
FirebaseInstanceId.getInstance().getToken
is deprecated.
To retrieve the current registration token for an app instance, you need to call
FirebaseMessaging.instance.getToken(); as stated here in their official guide.

Get product list from Huawei In app purchase

So, i want to get my products list from my Huawei developer account, i integrate the sdk and all it's fine. the issue here in this code :
Future<List<ProductInfo>> getConsumableProducts() async {
try {
ProductInfoReq req = ProductInfoReq(); // The named parameter 'skuIds' is required, but there's no corresponding argument.Try adding the required argument.dartmissing_required_argumentThe named parameter 'priceType' is required, but there's no corresponding argument.Try adding the required argument.dartmissing_required_argument
req.priceType = IapClient.IN_APP_CONSUMABLE;
req.skuIds = ["prod_01", "prod_02"];
ProductInfoResult res = await IapClient.obtainProductInfo(req);
return res.productInfoList; // A value of type 'List<ProductInfo>?' can't be returned from the method 'getConsumableProducts' because it has a return type of 'Future<List<ProductInfo>>'
} on PlatformException catch (e) {
log(e.toString());
return null;
}
}
i mention the issues in the code. P.S : i made a search and verify that this code is the same code which public
If you want to obtain purchase information, you could follow the code below:
List<String> productIdList = new ArrayList<>();
// Only those products already configured in AppGallery Connect can be queried.
productIdList.add("ConsumeProduct1001");
ProductInfoReq req = new ProductInfoReq();
// priceType: 0: consumable; 1: non-consumable; 2: subscription
req.setPriceType(0);
req.setProductIds(productIdList);
// Obtain the Activity object that calls the API.
final Activity activity = getActivity();
// Call the obtainProductInfo API to obtain the details of the product configured in AppGallery Connect.
Task<ProductInfoResult> task = Iap.getIapClient(activity).obtainProductInfo(req);
Check here for more info.

Initially publishing a github package shows "Username must not be null!"

I am trying to publish a package on Github using the Gradle part in Android Studio. It is not my first one but I cannot find what the difference is to the previous ones and why I get this error.
I can successfully run the build step and the files are in the output folder. However, when I run the step "publish", I get the following error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task
':config_properties_reader_android:publishBarPublicationToGitHubPackagesRepository'.
Failed to publish publication 'bar' to repository 'GitHubPackages'
-> Username must not be null!
The only difference I could find was that my module folder with the files to publish contains three instead of the usual two files:
Those two I would expect:
config_properties_reader_android/build/outputs/aar/config_properties_reader_android-debug.aar
config_properties_reader_android/build/outputs/aar/config_properties_reader_android-release.aar
And this one seems odd:
config_properties_reader_android/build/outputs/aar/configpropertiesreader-debug.aar
My gradle file looks like this:
apply plugin: 'maven-publish'
def githubProperties = new Properties()
githubProperties.load(new FileInputStream(rootProject.file("github.properties")))
def getVersionName = { ->
return "1.0.0"
}
def getArtificatId = { ->
return "config_properties_reader_android"
}
publishing {
publications {
bar(MavenPublication) {g
groupId 'com.MyGithubRepo'
artifactId getArtificatId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar")
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/MyGithubRepo/ConfigPropertiesReader.Android")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}
And my github.properties file also contains the usual:
gpr.user=myUser
gpr.key=myKey
Could the third file in the ouput folder be the problem? I do not see how the username should have anything to do with it but I have no idea where to look in order to find the error.
Try this in github.properties file
gpr.usr=myUser
gpr.key=myKey
Change gpr.user => gpr.usr
Also, use your git user-id in gpr.usr
and use git personal access token in gpr.key
i also have this issue this change solve mine problem
check the below line and replace the username and password it will work
file name is build.gradle
maven {
url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
credentials {
username 'braintree_team_sdk'
password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp'
}
}

Back4app issue in registering device with ionic 3

I m trying to use back4app for push notification. For this I have installed back4app's ionic sdk (https://www.back4app.com/docs/ionic/parse-ionic-sdk) like this
npm install parse
then in my app.component.ts I imported parse
import Parse from 'parse';
and in platform ready
Parse.serverURL = "https://parseapi.back4app.com/";
Parse.initialize("APP_ID_HERE", "JAVASCRIPT_KEY"); //I have used real keys from back4app dashboard.
let install = new Parse.Installation();
install.save(null, {
success: (install) => {
// Execute any logic that should take place after the object is saved.
// console.clear();
console.error('New object created with objectId: ' + install.id);
},
error: (install, error) => {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
//console.clear();
console.error('Failed to create new object, with error code:' + error.message.toString());
}
});
When I do Ionic serve or test it in device, it should register device/installation id to their backend but it gives 400 Bad Request error on https://parseapi.back4app.com/classes/_Installation the error was -
{"code":135,"error":"deviceType must be specified in this operation"}
I m not sure where to mention deviceType as their documentation doesn't seem that good.
Can anybody help me on this??
This is not mentioned in their documentation but I have found it in one of their example.
Replacing -
let install = new Parse.Installation();
with
let install = new Parse.Installation();
install.set("deviceType", platform.platforms().toString());
Solved the issue.
Here is the link to their repository
Parse SDK now supports Promises.
I'd recommend using it instead of passing in callbacks.
You can accomplish that by:
install.save().then(() => {
// success
}, err => {
// error
})

Azure mobile service doesn't register push notifications tags on Android

I'm trying to use the following code to send push notifications to specific users with tags (VS Cordova Project using Azure mobile service).
var tags = [userid, platform];
// Get the handle returned during registration.
var handle = data.registrationId;
// Set the device-specific message template.
if (platform == "android" || platform == "Android") {
// Template registration.
var template = '{ "data" : {"message":"$(message)"}}';
// Register for notifications.
mobileServiceClient.push.gcm.registerTemplate(handle,
"myTemplate", template, null, tags)
.done(registrationSuccess, registrationFailure);
} else if (platform == "iOS") {
// Template registration.
var template = '{"aps": {"alert": "$(message)"}}';
// Register for notifications.
mobileServiceClient.push.apns.registerTemplate(handle,
"myTemplate", template, null, tags)
.done(registrationSuccess, registrationFailure);
}
It registered successfully with the tags for Apple APNS , however on android it only registered the device, but the tags doesn't get registered.
I'm using push plugin 1.4.4 and Azure mobile service 1.2.9
Does anyone knows how to fix this? Any suggestion is appreciated, thanks!
After tracing the source code of azure mobile service plugin, I found that
gcm.prototype.registerTemplate = function (deviceId, name, bodyTemplate, tags)
is missing the "expiryTemplate" parameter. Changing it to
gcm.prototype.registerTemplate = function (deviceId, name, bodyTemplate, expiryTemplate, tags)
fix the problem.
My blog here details on how to receive notifications based on tags in a Cordova client. Basically you'll need a bit of server side code to update your installation / registration to handle specific tags. That's this bit of code:
NotificationHubClient _hub = NotificationHubClient.CreateClientFromConnectionString(notificationHubConnection, notificationHubName);
public async Task CreateOrUpdateInstallationAsync(string installationId, string registrationId, IEnumerable<string> tags)
{
Installation installation = new Installation();
installation.InstallationId = installationId;
installation.PushChannel = registrationId;
installation.Tags = tags.ToArray();
installation.Platform = NotificationPlatform.Gcm;
await _hub.CreateOrUpdateInstallationAsync(installation);
}