Giter Club home page Giter Club logo

react-native-sync-adapter's Issues

Can't change sync period

When I change syncInterval value and recompile the effective sync period is still 1 min.
I reproduce with the provided example project.

App not working

Capturar

I tried everything, I did everything right, but I can't do the job.

Expected to run on UI thread

Facing the error Expected to run on UI thread. When the task is running.

"react-native-sync-adapter": "^2.0.0",

Dependencies:
"react": "16.0.0-alpha.12",
"react-native": "0.48.1",

screen shot 2017-12-13 at 5 24 32 pm

Sometimes I am getting the error as Object is not a function (evaluating 'taskProvider()(data)')

Please help, I am struggling from past 2 days.
screen shot 2017-12-13 at 5 15 51 pm

App stops working if its in background

Im trying to integrate this in my RN project, every-time app goes background, the app crashes.

Logcat error output
Process: app.my.com, PID: 16407
java.lang.RuntimeException: Unable to start service com.fnp.reactnativesyncadapter.HeadlessService@89518c2 with Intent { cmp=app.my.com/com.fnp.reactnativesyncadapter.HeadlessService }: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3027)
at android.app.ActivityThread.-wrap17(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1442)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at com.facebook.react.HeadlessJsTaskService.getReactNativeHost(HeadlessJsTaskService.java:171)
at com.facebook.react.HeadlessJsTaskService.startTask(HeadlessJsTaskService.java:100)
at com.facebook.react.HeadlessJsTaskService.onStartCommand(HeadlessJsTaskService.java:52)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3010)
at android.app.ActivityThread.-wrap17(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1442) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417)

node_modules\react-native-sync-adapter\android\src\main\res\xml\authenticator.xml:2: AAPT: error: resource mipmap/ic_launcher (aka com.fnp.reactnativesyncadapter:mipmap/ic_launcher) not found

Environment

React native : 0.64.1

Description

When i tried to run the release apk build I am getting below error :
node_modules\react-native-sync-adapter\android\src\main\res\xml\authenticator.xml:2: AAPT: error: resource mipmap/ic_launcher (aka com.fnp.reactnativesyncadapter:mipmap/ic_launcher) not found

But this is not coming in case of debug apk.

Reproducible Demo

Better example

Send notifications when task is fired instead of making use of console.log.

Example not working

The given example is not logging anything ( or outputting"Headless JS task was fired!") at the chrome debug or "adb logcat" console, though the app is not running in the foreground (app closed). Could you please check this or if there is anything which I missed, let me know. Thanks.

Device : Moto E 1st Gen
OS: Android 5.1

PS: Wanted to use rn-sync-adapter to check location of the device every 3 mins in a production app

How to stop the headless task?

I have successfully implemented the react-native-sync-adapter and is working fine for the foreground and background sync. But the main issue is, I want to stop the sync interval task after single sync. I want to sync the data only once when user taps on the sync button in the application. Can anyone help me how to achieve that?

I am registering the task like:

const TASK_ID = 'TASK_SYNC_ADAPTER';

AppRegistry.registerComponent(appName, () => SyncAdapterExample);
AppRegistry.registerCancellableHeadlessTask(
    TASK_ID,
    () => TestTask,
    () => {},
);

And canceling the task after my operation has been completed in TestTask.js file like:

const TASK_ID = 'TASK_SYNC_ADAPTER';
AppRegistry.cancelHeadlessTask(TASK_ID, TASK_ID);

But I am getting an error while canceling the task:

TypeError: taskCancelProvider() is not a function. (In 'taskCancelProvider()()', 'taskCancelProvider()' is undefined)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.