OSPermissionSubscriptionState : Cannot resolve symbol - java

I'm trying to add push notification to my mobile native chat app. I'm trying to use OneSignal.
I can send manual push notification, so I think gradle part is okay
idsAvaiable method is deprecated, I started to looking for how can I get userId.
OSPermissionSubscriptionState status = OneSignal.getPermissionSubscriptionState();
String userId = status.getSubscriptionStatus().getUserId();
In here, I'm trying to get userId with status, but it's saying:
Cannot resolve symbol 'OSPermissionSubscriptionState'
How can I get userId?

Root cause
From OneSignal API 4.0.0, there are many APIs that have been removed including OSPermissionSubscriptionState.
Solution 1
Use OneSignal.getDeviceState()
OSDeviceState device = OneSignal.getDeviceState();
String userId = device.getUserId();
Solution 2
Use OneSignal.addSubscriptionObserver()
OneSignal.addSubscriptionObserver(new OSSubscriptionObserver() {
#Override
public void onOSSubscriptionChanged(OSSubscriptionStateChanges stateChanges) {
if (!stateChanges.getFrom().isSubscribed() && stateChanges.getTo().isSubscribed()) {
// Get user id
String userId = stateChanges.getTo().getUserId();
}
}
});
For more information, see the change log here.

Related

How to get Google Ads impressions based on location

I am working with Google Ads API. Based on my use case, I need to get the impressions, clicks, and other statistics about the products based on location(Without creating the campaign).
I contacted the Google Ads API team to address the issue but the doc reference they provided me didn't work in my case. (I'm not using keywords also)
generate forecast metrics
And also the query I used to access the data is...
public void queryTest(long customerId,String campaignId) {
try (GoogleAdsServiceClient googleAdsServiceClient =
googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) {
SearchGoogleAdsStreamRequest request =
SearchGoogleAdsStreamRequest.newBuilder()
.setCustomerId(Long.toString(customerId))
.setQuery("SELECT metrics.clicks, metrics.impressions,geographic_view.country_criterion_id FROM geographic_view WHERE geographic_view.country_criterion_id = 1009919")
.build();
ServerStream<SearchGoogleAdsStreamResponse> stream =
googleAdsServiceClient.searchStreamCallable().call(request);
for (SearchGoogleAdsStreamResponse response : stream) {
for (GoogleAdsRow googleAdsRow : response.getResultsList()) {
System.out.println("outPut"+googleAdsRow.getGeographicView());
}
}
}
}
Can someone please help me to resolve this issue??
Thank you!!

Stripe google pay Android - Unexpected developer error, please try again later

I faced an issue with google pay with stripe. The problem is that I fully
followed the documentation and get an obscure error. I have this onGooglePayResult and i always have Result.Failed with error - " java.lang.RuntimeException: Google Pay failed with error 10 " And error code 2.Feel free to ask i can answer on all your questions.
Main error is java.lang.RuntimeException: Google Pay failed with error 10:. This is coming in GooglePayPaymentMethodLauncher.Result.Failed. I really can't understand why this is producing, I've checked stripe documentation twice, google pay set up and everything, but can't find out.
I mean how to find out what is real error message is, I try to find anything related to this but unfortunatelythere is simply nothing of the kind.
Logcat - error = java.lang.RuntimeException: Google Pay failed with error 10: + error code = 2
private fun onGooglePayResult(
result: GooglePayPaymentMethodLauncher.Result
) {
when (result) {
is GooglePayPaymentMethodLauncher.Result.Completed -> {
// Payment details successfully captured.
// Send the paymentMethodId to your server to finalize payment.
val paymentMethodId = result.paymentMethod.id
presenter.payPlanWithGooglePay(deviceIdentifier, paymentMethodId)
}
GooglePayPaymentMethodLauncher.Result.Canceled -> {
// User cancelled the operation
Timber.d("Cancel")
}
is GooglePayPaymentMethodLauncher.Result.Failed -> {
// Operation failed; inspect `result.error` for the exception
Timber.d("error = ${result.error} + error code = ${result.errorCode}")
}
}
}
I've resolved this issue, was my fault. I forget to add the PUBLISHABLE key from the stripe developer portal.
I use this function to set up Google pay. Just substitute TEST_PUBLISHABLE_KEY with your key in stripe account(Website).
private fun setUpGooglePay(): GooglePayPaymentMethodLauncher {
PaymentConfiguration.init(this, TEST_PUBLISHABLE_KEY)
return GooglePayPaymentMethodLauncher(
activity = this,
config = GooglePayPaymentMethodLauncher.Config(
environment = GooglePayEnvironment.Test,
merchantCountryCode = Constants.GooglePay.Manx.COUNTRY_CODE,
merchantName = UIUtils.getString(R.string.app_name)
),
readyCallback = ::onGooglePayReady,
resultCallback = ::onGooglePayResult
)
}

Network error on some devices after build

I installed the app after build on different devices (Android) the app opens up fine but when sending network request only one of the device is able to send successfully the others remain unresponsive.
Am using the Rest.post() to send that particular request.
Using codename one 6.0 but updated it this morning so I will be using the recent version.
Note: the situation happened before the update. i added a bunch of things while trying to locate the problem.
Here is the code:
//...Login button ActionListner
gui_Button_login.addActionListener((ae)->{
gui_Infinite_Progress.setVisible(true);
gui_Infinite_Progress.setEnabled(true);
gui_Button_login.setEnabled(false);
gui_Text_Field_username.setEnabled(false);
gui_Text_Field_Password.setEnabled(false);
if(doLogin()){
Handle.UserFeed = new UserFeedForm();
Handle.UserFeed.show();
}else{
gui_Button_login.setEnabled(true);
gui_Text_Field_username.setEnabled(true);
gui_Text_Field_Password.setEnabled(true);
gui_Infinite_Progress.setVisible(false);
gui_Infinite_Progress.setEnabled(false);
}
});
//...Do login function
private boolean doLogin(){
String usr_username = gui_Text_Field_username.getText();
String usr_password = gui_Text_Field_Password.getText();
Map<String, Object> signInData = new HashMap<>();
signInData.put("usr_username", usr_username);
signInData.put("usr_password", usr_password);
String signInDataJSON = JSONParser.mapToJson(signInData);
gui_Span_Label_Debug.setText(gui_Span_Label_Debug.getText() +"\nData:\n"+ signInDataJSON);
gui_Span_Label_Debug.setText(gui_Span_Label_Debug.getText() +"\nSending...");
Response<Map> response = Rest.post(Data.API_SIGNIN_URL)
.jsonContent()
.body(signInDataJSON)
.acceptJson()
.onErrorCodeJSON(err->{
ToastBar.showErrorMessage(err.getResponseErrorMessage(), Data.MESSAGE_ERROR_TIMEOUT);
//gui_Span_Label_Debug.setText(gui_Span_Label_Debug.getText() +"\nError:\n"+ err.getResponseErrorMessage());
}).getAsJsonMap();
Map<String, Object> responseData = response.getResponseData();
if(response.getResponseCode() == 0){
ToastBar.showErrorMessage("Please check your internet!", Data.MESSAGE_ERROR_TIMEOUT);
}
gui_Span_Label_Debug.setText(gui_Span_Label_Debug.getText() +"\nResponse Code:\n"+ response.getResponseCode());
gui_Span_Label_Debug.setText(gui_Span_Label_Debug.getText() +"\nResponse Error Msg:\n"+ response.getResponseErrorMessage());
if(responseData == null){
return false;
}
if(((String)responseData.get("status")).equalsIgnoreCase("error")){
ToastBar.showErrorMessage((String)responseData.get("msg"), Data.MESSAGE_ERROR_TIMEOUT);
return false;
}
if(((String)responseData.get("status")).equalsIgnoreCase("success")){
ToastBar.showMessage((String)responseData.get("msg"), FontImage.MATERIAL_CHECK_CIRCLE, Data.MESSAGE_SUCCESS_TIMEOUT);
Handle.LoggedInUserData = (Map<String, Object>) responseData.get("data");
Handle.Authority = (String)Handle.LoggedInUserData.get("jwt");
return true;
}
return false;
}
//...
Data.API_SIGNIN_URL is a string containing address accessible via internet e.g. http://94.543.23.4/
I'm guessing you are trying to connect via an IP to a specific machine and it isn't working. This machine is probably visible only within your internal network and the other devices aren't connected to the internal network or choose a route via cell towers.
well i added the build hint android.xpermissions and set the value to android.permission.INTERNET\=true,android.permission.WRITE_EXTERNAL_STORAGE\=true,android.permission.READ_EXTERNAL_STORAGE\=true.
Its working but seems redundant to me since according to codenameone docs Internet permission is inserted by default. i added the storage just to avert possible similar situation

REST Service - org.hibernate.QueryException: could not resolve property error

I am trying to send data from my android app to my REST service so that it can be stored on a database. I have successfully done this in another app that I have worked on and when I am trying to do it with this project I am getting this error:
org.hibernate.QueryException: could not resolve property: line_type
In my Oracle Database the field is named "LINE_TYPE" and is VARCHAR2(20 BYTE).
Here is the code in my REST service table (which I have reverse engineered from my oracle database):
private String lineType;
#Column(name="LINE_TYPE")
#Size(max = 20, message = "Line Type has a max size of 20 characters.")
public String getLineType() {
return this.lineType;
}
public void setLineType(String lineType) {
this.lineType = lineType;
}
Also in my tableCriteria I have the getters and setters:
public String getLineType() {
return lineType;
}
public void setLineType(String lineType) {
this.lineType = lineType;
}
The last time I had this error it was through a spelling mistake or case sensitivity but I have double and triple checked and that is not the case here.
I have debugged the entity that the REST service is receiving in NetBeans and I can see that it is receiving the data. So why cant it be resolved?
Anyone see anything I don't?

Azure MobileServices on Android returns "The id must be numeric" on updates

I am programming an android program where links to my Azure with MobileService on Android.'
During execution of a similar update statement which can be found here, it returns as error "java.lang.IllegalArgumentException: The id must be numeric".
I am using the follow codes:
mTable.update(item, new TableOperationCallback<EntityTest>() {
public void onCompleted(EntityTest result,
Exception exception, ServiceFilterResponse response) {
if (exception == null) {
Toast.makeText(getApplicationContext(), "Successfully updated!", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), exception+"///"+response, Toast.LENGTH_SHORT).show();
}
}
});
Any help is gladly and hugely appreciated!
I'm not completely positive but Mobile Services recently changed over to a new model for the ID column on tables (it use to be integer based but is now String based). I would guess you're using an old version of the SDK which assumes it's going to get back integers for the ID column when now it will return strings. I would suggest downloading the latest version of the SDK and making sure your data model class (EntityTest from the looks of your code) is expecting a String ID and not an int.

Categories

Resources