React Native Webview Clear Cache - react-native

Is there a way to clear cache in webview for both ios and android?
I tried using #react-native-community_cookies, it works for ios, but for android Im getting this error when trying to run: A problem occurred evaluating project ':#react-native-community_cookies'. > Plugin with id 'maven' not found.
Maybe any of you have suggestions how to fix this or know some other methods?
Thanks

You can use this plugin https://www.npmjs.com/package/#react-native-community/cookies for clear cache and write below function
import CookieManager from '#react-native-community/cookies';
CookieManager.clearAll(true)
The true param means that it will clear cookies for the webkit webview (which is what this library uses)

Check out this library it does the job done.
https://github.com/react-native-cookies/cookies
import CookieManager from '#react-native-cookies/cookies';
CookieManager.clearAll(true);

Related

How to setup feathers offline in react native

I would like to know if anyone successfully set up feathers offline in react native. Right now I am having an issue whenever I call "owndataWrapper" i.e
import { owndataWrapper } from '#feathersjs-offline/client';
owndataWrapper(app, '/messages', {});
The error says Unable to resolve module path in /node-localstorage/LocalStorage.js . . so I ended up installing these packages.
assert, constants, events, path, stream, and fs
and got a new error.
here is the error.
https://github.com/feathersjs-offline/owndata-ownnet/issues/46
My guess is probably due to the fs package, it has a security issue.
Any idea? Thanks
After digging further it turns out it only works on web apps. It uses packages that does not exists in react native such as path, process, fs, and so on. I tried using
https://github.com/parshap/node-libs-react-native
and
https://github.com/staltz/react-native-process-shim
but got stuck and continuesly having error on fs. . in conclusion I need to drop the ball for now since this feathers offline is not yet fully created for react native.

How to make react-native alarm clock?

I try to make simple alarm clock. I found this npm : www.npmjs.com/package/react-native-alarm-clock
But when I add everything and start project it gives me error on Command Prompt :
cannot find symbol
import com.liang.RNAlarmClockPackage;
How do I solve problem and any alternative to make alarm clock ?
After checking the link you have shared i found out that there are mistakes in the commands show in given link.
e.g react-native link react-native-alarm in place of react-native link react-native-alarm-clock
You can try out below packages
react-native-calendar-events
react-native-alarm-notification
I also tried using react-native-alarm-clock in the past, and was unable to make it work.
I made a react native library for alarm clock functionality that also includes an example: react-native-simple-alarm
If you don't want to install an library, you can make the alarm functions using react-native-push-notification

Using styleguidist in a react native application

I'm trying to use styleguidist in a react native application application;
I come across this link and implemented the exact same set up in my application:
https://github.com/styleguidist/react-styleguidist/tree/master/examples/react-native
After running npx styleguidist build, i got this output:
FAIL Failed to compile
build/bundle.f44bbfd4.js from UglifyJs
Unexpected token punc «:», expected punc «,» [build/bundle.f44bbfd4.js:372,1165]
Any ideas how to solve this ?
Thanks in advance.
Can you please provide more examples of what exact code changes you made and to what files? I had a similar issue and it turned out I was applying config changes to webpack.config.js that needed to go into the styleguide.config.js instead.

Not able to show image (API setDrawIcons() not found error)

I am using MPAndroidChart in our android project to show graph and it's very helpful. Using latest version 3.0.1 (https://github.com/PhilJay/MPAndroidChart#usage)
I have some requirement to show image on top of BarEntry after some condition met. Same is working in example code downloaded.
BarDataSet set1;
set1.setDrawIcons(true);// Cannot resolve method 'setDrawIcons(boolen)
Why the above API is not part of library MPChartLib, am I missing something here?
Above problem got solved after integrating MPChartLib source code.
File -> Project Structure
click plus button to add New Module
Import Gradle Project
from Source directory: and finish.
The setDrawIcons method was added in 3.0.2. Change your Gradle option to read compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'

Unable to resolve module ReactNativeEventEmitter

After upgrading React Native from 0.29 to 0.30, I get this error message. I multiple times deleted node_modules, installed them back again, cleared watchman cache and npm start --reset-cache.
I tried it also on new project with react-native init someProject. The same error. Was this module renamed or deleted? I haven't found any info about it in release notes or in commits.
Thanks for help!
It's no longer needed. onTouchStart, onTouchEnd and onTouchMove are props of Views now.
Look here
I don't know, what really happened to this component.
But, at least, currently on RN 0.30 you can require ReactNativeEventEmitter as follows:
var ReactNativeEventEmitter=require(127);
The following line ...
console.log(ReactNativeEventEmitter)
...will print then this in the console (in Debug-Mode):
(I've figured it out while searching the react-native libraries in "node-modules" in the following file: "./node_modules/react-native/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js:13879", and it is also working under iOS [the screenshot above originates from iOS]).
Have you tried to import using below snippet?
import { DeviceEventEmitter } from 'react-native';