I used "react-native-push-notification": "^8.1.1", It works very well in debug but notifications do not display in release apk, and (my android version: 12)
React native push notifications have an issue if the Android target SDK is > 30 you can check this issue in github
To fix it you will need to patch the library using this patch:
diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
index ad3527b..447a540 100644
--- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
## -455,8 +455,13 ## public class RNPushNotificationHelper {
int notificationID = Integer.parseInt(notificationIdString);
- PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationID, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = null;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
+ pendingIntent = PendingIntent.getActivity(context, notificationID, intent, PendingIntent.FLAG_MUTABLE);
+ }
+ else {
+ pendingIntent = PendingIntent.getActivity(context, notificationID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ }
NotificationManager notificationManager = notificationManager();
This solution is already on github.
Related
I am trying to understand the address system in the plac4x java implementation. Below an example of the reading code of the plcs:
#Test
void testReadingFromPlc() {
// Establish a connection to the plc using the url provided as first argument
try( PlcConnection plcConnection = new PlcDriverManager().getConnection( "modbus:tcp://1.1.2.1" ) ){
// Create a new read request:
// - Give the single item requested the alias name "value"
var builder = plcConnection.readRequestBuilder();
builder.addItem( "value-" + 1, "register:1[9]" );
builder.addItem( "value-" + 2, "coil:1000[8]" );
var readRequest = builder.build();
LOGGER.info( "Synchronous request ..." );
var syncResponse = readRequest.execute().get();
// Simply iterating over the field names returned in the response.
var bytes = syncResponse.getAllByteArrays( "value-1" );
bytes.forEach( item -> System.out.println( TopicsMapping.byteArray2IntegerArray( item )[0] ) );
var booleans = syncResponse.getAllBooleans( "value-2" );
booleans.forEach( System.out::println );
}catch(Exception e){
e.printStackTrace();
}
}
Our PLCs manage 16 registers, but the regex of the addresses don't allow to have a quantity bigger than 9. Is it possible to change this?
Moreover, if I try to add an other field with the same purpose then no reading happen:
var builder = plcConnection.readRequestBuilder();
builder.addItem( "value-" + 0, "register:26[8]" );
builder.addItem( "value-" + 1, "register:34[8]" );
builder.addItem( "value-" + 2, "coil:1000[8]" );
var readRequest = builder.build();
Any help much appreciated. Could you also show me where I can find more information on this framework?
I am reading and writing using the modbus driver in PLC4x with success. I have attached some writing code to your other question at: Plc4x addressing system
About reading, here is some code:
public static PlcReadResponse readModbusTestData(ProtocolClient client,
String registerName,
int offset,
int size,
String registerType)
throws ExecutionException, InterruptedException, TimeoutException {
PlcReadRequest readRequest = client.getConnection().readRequestBuilder()
.addItem(registerName, registerType + ":" + offset + "[" + size + "]").build();
return readRequest.execute().get(2, TimeUnit.SECONDS);
}
The multiple read adding more items to the PlcReadRequest has not been tested yet by me, but it should work. Writing several items is working.
In any case, in order to understand how PLC4x works for modbus or opc-ua I have needed to dive into the source code. It works, but you need to read the source code for the details at its current state.
I get the following dmesg output from my kernel created with yocto.
bus: 'i2c': add driver edt_ft5x06
bus: 'i2c': driver_probe_device: matched device 1-0038 with driver edt_ft5x06
bus: 'i2c': really_probe: probing driver edt_ft5x06 with device 1-0038
edt_ft5x06 1-0038: no default pinctrl state
edt_ft5x06 1-0038: probe
edt_ft5x06 1-0038: no platform data?
edt_ft5x06: probe of 1-0038 failed with error -22
i2c-core: driver [edt_ft5x06] registered
My device tree contains:
smarc_i2c_cam: i2c-gpio-1 {
compatible = "i2c-gpio";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_smx6_i2c_gpio_1>;
gpios =
<&gpio4 10 0>, /* sda */
<&gpio1 6 0>; /* scl */
#address-cells = <1>;
#size-cells = <0>;
i2c-gpio,delay-us = <2>;
};
polytouch: edt-ft5x06#38 {
compatible = "edt,edt-ft5x06";
reg = <0x38>;
pinctrl-names = "default";
//pinctrl-1 = <&edt_ft5x06_pins>;
interrupt-parent = <&gpio3>;
interrupts = <1 8>;
};
My board is smarc-samx6i (imx6q "Freescale" processor).
Linux kernel is 3.10.17.
But touch is not responding; even the i2c is not responding. Is there anything else I need to take care of?
I have a lenmaker 7inch touch screen with the "EDT-FT5x06" touch controller on a Lenmaker BananaPro (A20) running on a mainline linux kernel 4.6.
Here is the patch of my device tree. Look at the wake-gpios and the interrupts.
diff --git a/arch/arm/boot/dts/sun7i-a20-bananapro.dts b/arch/arm/boot/dts/sun7i-a20-bananapro.dts
index 18fcc87..50f1a36 100644
--- a/arch/arm/boot/dts/sun7i-a20-bananapro.dts
+++ b/arch/arm/boot/dts/sun7i-a20-bananapro.dts
## -147,6 +147,26 ##
status = "okay";
};
+&i2c3 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3_pins_a>;
+ edt: edt-ft5x06#38 {
+ compatible = "edt,edt-ft5x06";
+ reg = <0x38>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 9 IRQ_TYPE_EDGE_FALLING>;
+ wake-gpios = <7 7 GPIO_ACTIVE_LOW>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&edt_ft5x06_pins>;
+ touchscreen-size-x = <1024>;
+ touchscreen-size-y = <600>;
+ touchscreen-inverted-x;
+ touchscreen-swapped-x-y;
+ };
+};
+
+
&ir0 {
pinctrl-names = "default";
pinctrl-0 = <&ir0_rx_pins_a>;
## -222,6 +242,14 ##
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};
+
+ edt_ft5x06_pins: edt_ft5x06_pins#0 {
+ allwinner,pins = "PH7", "PH9";
+ allwinner,function = "gpio_out";
+ allwinner,drive = <SUN4I_PINCTRL_40_MA>;
+ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+ };
+
};
®_usb1_vbus {
Maybe you found more in this documentation from the linux kernel module: https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
or here: http://linux-sunxi.org/Touchscreen
The edt ft5x06 driver in 3.10.17 kernel is not device tree enabled. You will have to backport the driver from a more recent kernel like 4.1 or later and then you will be able to use device trees with the driver.
My preloader works fine with previous version of createjs
but latest version of createjs it does not work. so what the update needed ?
loader.onProgress = handleProgress;
stage = new createjs.Stage(canvas);
createjs.Ticker.setFPS(22);
createjs.Ticker.addEventListener("tick", stage);
var progress = new createjs.Shape();
var progressBellow = new createjs.Shape();
var txt = new createjs.Text();
progress.graphics.beginStroke("#280000").drawRect(115,112,400,40);
progressBellow.graphics.beginStroke("#280000").drawRect(115,112,400,40);
txt.x = 150;
txt.y = 190;
txt.font = ("25px Verdana");
txt.color = ("#f11c35");
function handleProgress(event) {
progress.graphics.clear();
// Draw the progress bar
progress.graphics.beginFill("#92ba17").drawRect(115,112,400*(event.loaded / event.total),40);
txt.text = ("Loading " + 100*(event.loaded / event.total) + "%");
}
stage.addChild(progress,progressBellow,txt);
stage.update();
There is no onProgress callback. Callbacks were removed a few versions ago (2013?) when bubbling events were added (the two methods aren't compatible).
Use an event instead:
loader.on("progress", handleProgress);
// OR
loader.addEventListener("progress", handleProgress);
Hope that solves your issue.
We have tried the approach suggested at:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn312121(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/hardware/dn303343(v=vs.85).aspx
We are able to find out list of all the magneticDevices using below code snippet
var magneticDevices = await DeviceInformation.FindAllAsync(aqsFilter);
but we are not able to get HidDevice object from the below code. It is giving null.
HidDevice device = await HidDevice.FromIdAsync(magneticDevices[0].Id
We have also set device capabilities in the app manifest file like below.
<DeviceCapability Name="humaninterfacedevice">
<Device Id="vidpid:0ACD 0520">
<Function Type="usage:0001 0006"/>
</Device>
</DeviceCapability>
<DeviceCapability Name="usb">
<Device Id="vidpid:0ACD 0520">
<Function Type="winUsbId:4d1e55b2-f16f-11cf-88cb-001111000030"/>
</Device>
</DeviceCapability>
Code for the complete Function
private async Task<bool> HasCardReader()
{
bool hasCardReader = false;
ushort usagePage = 0x0001;
ushort usageId = 0x0006;
ushort vendorId = 0x0ACD;
ushort productId = 0x0520;
var aqsFilter = HidDevice.GetDeviceSelector(usagePage, usageId, vendorId, productId);
var magneticDevices = await DeviceInformation.FindAllAsync(aqsFilter);
try
{
if (magneticDevices != null && magneticDevices.Count > 0)
{
HidDevice device = await HidDevice.FromIdAsync(magneticDevices[0].Id, Windows.Storage.FileAccessMode.Read);
inputReportEventHandler = new TypedEventHandler<HidDevice, HidInputReportReceivedEventArgs>(this.OnInputReportEvent);
device.InputReportReceived += inputReportEventHandler;
var watcher = DeviceInformation.CreateWatcher(aqsFilter);
watcher.Added += WatcherAdded;
watcher.Removed += WatcherRemoved;
watcher.Start();
hasCardReader = true;
}
else
{
}
}
catch (Exception ex)
{
Logging.LoggingSessionScenario.LogMessageAsync(ex.Message, LoggingLevel.Error);
}
return hasCardReader;
}
There are several reasons for the null return value, but I don't think there is something wrong with your code, since you can find the device by calling FindAllAsync. I will suggest you to troubleshoot this issue using this official HIDDevice sample on GitHub.
I successfully connected to my external hid device with that sample by changing the vid & pid & usagepage & usageid to my device.
In EventHandlerForDevice.cs, find the function OpenDeviceAsync, and you will notice the following possible reasons when null is returned by FromIdAsync.
else
{
successfullyOpenedDevice = false;
notificationStatus = NotifyType.ErrorMessage;
var deviceAccessStatus = DeviceAccessInformation.CreateFromId(deviceInfo.Id).CurrentStatus;
if (deviceAccessStatus == DeviceAccessStatus.DeniedByUser)
{
notificationMessage = "Access to the device was blocked by the user : " + deviceInfo.Id;
}
else if (deviceAccessStatus == DeviceAccessStatus.DeniedBySystem)
{
// This status is most likely caused by app permissions (did not declare the device in the app's package.appxmanifest)
// This status does not cover the case where the device is already opened by another app.
notificationMessage = "Access to the device was blocked by the system : " + deviceInfo.Id;
}
else
{
// Most likely the device is opened by another app, but cannot be sure
notificationMessage = "Unknown error, possibly opened by another app : " + deviceInfo.Id;
}
}
Have a try with that sample(Scenario1) and change the ids in both appxmanifest and SampleConfiguration.cs(class Device). If you cannot see your device in the device list, that means the configuration is incorrect for your device.
I am stuck badly with the following issue, please help me out with a working solution.
For all touch actions I am getting
org.openqa.selenium.WebDriverException: unimplemented command: session/537d48a9dcdfb38a12ff318a302c9a08/touch/scroll
Command duration or timeout: 8 milliseconds
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'Praveen-Prabhus-MacBook-Pro.local', ip: '192.168.0.42', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.7.0_65'
Session ID: bbe122fa-f325-4142-a555-9d2f4ea60e02
Driver info: core.AppiumSwipeableDriver
public class AppiumSwipeableDriver extends AppiumDriver implements HasTouchScreen{
public RemoteTouchScreen touch;
public AppiumSwipeableDriver(URL URL, Capabilities Cap) {
super(URL, Cap);
touch = new RemoteTouchScreen(getExecuteMethod());
}
#Override
public TouchScreen getTouch() {
return touch;
}
}
if(browser.equalsIgnoreCase("android")){
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
capabilities.setCapability("deviceName","Android");
capabilities.setCapability("device","Android");
capabilities.setCapability("takesScreenshot","true");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("platformVersion","4.4.2");
capabilities.setCapability(CapabilityType.PLATFORM,"Mac");
capabilities.setCapability("appPackage","uk.co.ee.myee");
capabilities.setCapability("appActivity","uk.co.ee.myee.Launcher");
capabilities.setCapability("udid","26d7be7b");
driver = new AppiumSwipeableDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
touch = new TouchActions(driver);
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
if (contextName.contains("WEBVIEW_uk.co.ee.myee")){
driver.context(contextName);
}
}
public boolean TopUpRegisteredCard(){
try{
waitForVisible(By.xpath(OR.getProperty("wblTopUpWidget")),10);
driver.findElement(By.xpath(OR.getProperty("wblTopUpWidget"))).click();
waitForVisible(By.xpath(OR.getProperty("btnTopUpRegisteredCard")),10);
driver.findElement(By.xpath(OR.getProperty("btnTopUpRegisteredCard"))).click();
waitForVisible(By.xpath(OR.getProperty("txtTopUpPaymentAmt")),10);
driver.findElement(By.xpath(OR.getProperty("txtTopUpPaymentAmt"))).sendKeys("10");
driver.findElement(By.xpath(OR.getProperty("txtTopUpCVVNum"))).sendKeys("123");
touch.flick(driver.findElement(By.xpath(OR.getProperty("txtTopUpCVVNum"))),0,-250,1000).perform();
waitForVisible(By.xpath(OR.getProperty("btnTopUpMakePayment")),10);
driver.findElement(By.xpath(OR.getProperty("btnTopUpMakePayment"))).click();
return true;
}catch(Exception e){
ReportTest.error(e.getMessage());
return false;
}
I have also tried with AppiumDriver - TouchAction and that gives me
org.openqa.selenium.UnsupportedCommandException: unknown command: session/9e5f0b55fdfb2c98dd019f44a7bf9c8a/touch/perform
I have ran the same scripts shown above successfully in a Windows machine,but now I have moved my project to a MAC and there after its not functioning as expected.
Please help me to get this fixed
Actually now Touch Actions are not supported for webview. But some workarounds are available; I am going to show it with a longpress example : I am using Pointoption because i will get the coordinate of element and will use it for longpress.
public void longpress(PointOption po) {
//first you need to switch to native view
driver.switchToNativeView();
TouchAction action = new TouchAction((PerformsTouchActions) driver);
action.longPress(po).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(2)));
action.release();
action.perform();
driver.switchToDefaultWebView();
}
For to get the coordinate of element i designed below methood
public PointOption getElementLocation(WebElement element) {
int elementLocationX;
int elementLocationY;
//get element location in webview
elementLocationX = element.getLocation().getX();
elementLocationY = element.getLocation().getY();
//get the center location of the element
int elementWidthCenter = element.getSize().getWidth() / 2;
int elementHeightCenter = element.getSize().getHeight() / 2;
int elementWidthCenterLocation = elementWidthCenter + elementLocationX;
int elementHeightCenterLocation = elementHeightCenter + elementLocationY;
//calculate the ratio between actual screen dimensions and webview dimensions
float ratioWidth = device.getDeviceScreenWidth() / ((MobileDevice) device)
.getWebViewWidth().intValue();
float ratioHeight = device.getDeviceScreenHeight() / ((MobileDevice) device)
.getWebViewHeight().intValue();
//calculate the actual element location on the screen , if needed you can increase this value,for example i used 115 for one of my mobile devices.
int offset = 0;
float elementCenterActualX = elementWidthCenterLocation * ratioWidth;
float elementCenterActualY = (elementHeightCenterLocation * ratioHeight) + offset;
float[] elementLocation = {elementCenterActualX, elementCenterActualY};
int elementCoordinateX, elementCoordinateY;
elementCoordinateX = (int) Math.round(elementCenterActualX);
elementCoordinateY = (int) Math.round(elementCenterActualY);
PointOption po = PointOption.point(elementCoordinateX, elementCoordinateY);
return po;
}
now you have a longpress(PointOption po) and getElementLocation(Webelement element) methods that gives you po value to use in longpress method. Now everything is ready and you can use them as below..
longpress(getElementLocation(driver.findElement(By.id("the selector can be any of them(xpath,css,classname,id etc.)")));