Display red screen error in react native from a native module - react-native

I implemented a native module and I would like to display an error for a developer using the redbox error screen from the native module. This error will inform about obsolete values.
Does anyone know, how to display this kind of screen with a custom message?
Below I am attaching a screenshot, what I would like to achieve:

On android you can achieve this with the following code:
val exceptionManager = reactContext.getNativeModule(ExceptionsManagerModule::class.java)
val error: WritableMap = WritableNativeMap()
error.putString("message", "Error message")
exceptionManager.reportException(error)
on iOS it's also quite straightforward:
let exceptionsManager = bridge.module(forName: "RCTExceptionsManager") as? exceptionsManager
exceptionsManager?.reportFatalException("message", stack: nil, exceptionId: 1)

Related

How to change toast message's default icon in jetpack compose?

I have a toast message in my code and it shows when user enter empty dictionary name but there is a problem for me toast shows message with a default android icon and I don't want this. How can I change this icon or remove in jetpack compose kotlin ?
here is screen shot.
Hear is my code
fun updateDictionary(context: Context, dictionaryName: String): Boolean {
if (dictionaryName.isEmpty()) {
Toast.makeText(context, "Please Enter The Dictionary Name !", Toast.LENGTH_LONG).show()
return false
}
val dictionary = OwnDicEntity(dictionaryName, dicCreationTime ?: "", dicId)
updateDicUseCase.updateDic(dictionary)
return true
}
if I want to update dictionary , I go to the update screen and this function is triggered and I have to write update dictionary name if I enter empty dictionary name. it shows toast message as I wrote above.
I'm returning a boolean value, true and false, so that it doesn't update when I enter a empty value.
Starting with Android 12 you don't get any control over how Toasts look - you get two lines of text and your application icon, so the user knows where the Toast came from. (Android 11 still allows for a custom view, but only for apps in the foreground.)
If you want to change the icon, you need to add a new one for your app - the one you're seeing is the default ic_launcher drawable for a new project. Some info about that here.
If you want to remove the icon, you can't! Since you seem to be displaying this as a popup in your own app, you might want to consider a Snackbar instead, or setting the error hint on a text field, or maybe create an area of your UI dedicated to displaying any errors (e.g. if there are multiple components you need to validate, and you want the error state in one place).

How can i give gradient to text in react-native expo?

I tried
import { LinearTextGradient } from "react-native-text-gradient";
but this is not work for text gradient. It gives error. it says "No ViewManager defined for class RNLinearTextGradient"
i need to give gradient to text for ios and android

ARCore: accessing camera image data from frame.acquireCameraImage

I have an app in Java which needs to get the camera image from ARCore for custom rendering. Recently, two new APIs have been added to ARCore (v1.1.0) which should support this. Well, everything else works for me except these two calls. Both calls are failing with same error (SIGINIT):
SIGINIT
and I have this message in the Logcat:
04-18 14:52:32.007 32623-32623/ A/Ion: [java/com/google/vr/dynamite/client/native/dynamite_client.cc:74] CHECK failed: expression='"env"'
04-18 14:52:32.007 32623-32623/ A/Ion: Dumping stack:
relevant code is:
try
{
// Obtain the current frame from session.
mSession.setCameraTextureName( mTextureId );
Frame frame = mSession.update();
TrackingState trackingState = frame.getCamera().getTrackingState();
if ( trackingState == TrackingState.TRACKING )
{
// Compute lighting, this is also crashing
//final float[] colorCorrectionRgba = new float[4];
//frame.getLightEstimate().getColorCorrection( colorCorrectionRgba, 0 );
//getPixelIntensity works fine
float lightIntensity = frame.getLightEstimate().getPixelIntensity();
Log.d( TAG, " light intensity is " + lightIntensity );
//This is also crashing
android.media.Image image = frame.acquireCameraImage();
//do something useful with the image
image.close();
app level build.gradle has the following entry under dependencies:
implementation 'com.google.ar:core:1.1.0'
and I have tried this with both proguard enabled and disabled.
Can anyone spot what I am doing wrong?
PS: In case it's not clear, the failing calls are frame.acquireCameraImage() and frame.getLightEstimate().getColorCorrection().

AIR native extension: Can I call ActionScript 3 method from C/Objective-C?

I have an AIR application that uses a native extension to create a series of dialogs the user navigates through. After the user navigates through the dialogs, I need the C/Objective-C side to notify the AIR app that the user finished as well as forward the series of choices the user made.
Is that possible?
IE: the C/ObjC equivalent of
public function evokeMyASMethod(choice0:int,choice1:int):Boolean
{
// context opens the native extension to the AS3 side
var success:Boolean = context.call("myASMethod", choice0, choice1) as Boolean;
return success;
}
An alternate solution is to start a timer in ActionScript that pings the native extension periodically to check whether the user has finished and fetch the values, but that seems so messy that I think I must be missing something obvious.
Any help is much appreciated. Thanks!
What you'll need to do is dispatch "status" events from the native code and then listen for them in your AS3 code.
So firstly in your AS3 code add a listener to your extension context:
context.addEventListener( StatusEvent.STATUS, onStatus);
private function onStatus( event:StatusEvent ):void
{
trace( "code = " + event.code );
trace( "level = " + event.level );
}
The code and level variables are two strings you can pass back from your native code. In your ObjC code you'll use the FREDispatchStatusEventAsync function to fire an event back to your AS3 code:
FREDispatchStatusEventAsync( yourFreContext, (const uint8_t*)"code", (const uint8_t*)"level" );
You just need to change the "code" and "level" strings as you see fit and process them in your onStatus handler.
More information here:
http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b143961a5e412937b5d5c6-7ffc.html
http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-7ff5.html

Windows 8 app with FabricJS Free Drawing Support?

I'm trying to implement free drawing in my windows 8 app but I keep getting this error:
"0x800a01bd - JavaScript runtime error: Object doesn't support this action
File: fabric.js, Line: 12857, Column: 7"
Adding images to the canvas etc. all works as it does in the demos but in VS when I hovered over "fabric" in this code, fabric.Shadow is not shown as an option in the list:
setShadow: function(options) {
return this.set('shadow', new fabric.Shadow(options));
},
Does anyone know why this isn't working for me? I created a build of the api from www.fabricjs.com and included all modules. I've copied the code from the free drawing demo (http://fabricjs.com/freedrawing/) but no joy. I also tried removing any reference to creating a shadow as I don't plan on using that functionality but it still crashes. Thank you
Thank you! It's working for me now. I did have to change the JavaScript provided by the demo to make it work though. Just as a reference to anyone who may want to use it with Windows 8 in future, the jquery code needs to be made more strict for it to update the selectors.
Provided code:
var $ = function(id){return document.getElementById(id)};
var drawingModeEl = $('drawing-mode'),
drawingOptionsEl = $('drawing-mode-options'),
drawingColorEl = $('drawing-color'),
drawingShadowColorEl = $('drawing-shadow-color'),
drawingLineWidthEl = $('drawing-line-width'),
drawingShadowWidth = $('drawing-shadow-width'),
drawingShadowOffset = $('drawing-shadow-offset'),
clearEl = $('clear-canvas');
I did away with the above and just used the standard jquery selector $('#drawing-mode') each time I needed it. Then the events were provided as:
drawingModeEl.onclick = function() {}
drawingColorEl.onchange = function() {}
so I changed the above to:
$('#drawing-mode').on('click', function () {});
$('#drawing-color').change(function (){});
Now everything works as it does in the demo. Love this API, thank you!