Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple screenshot events on single screenshot #15

Closed
timothyerwin opened this issue Jun 8, 2021 · 5 comments · Fixed by #33
Closed

Multiple screenshot events on single screenshot #15

timothyerwin opened this issue Jun 8, 2021 · 5 comments · Fixed by #33

Comments

@timothyerwin
Copy link

As mentioned in the header I am getting 3 screenshot calls when I take a single screenshot...

I checked that it only registers the listener once...any ideas?

import {
  addScreenshotListener,
  removeScreenshotListener,
} from 'react-native-detector';

async componentDidMount() {
    this.screenshot = this.screenshot || addScreenshotListener(() => {
      console.log('screenshot');

      toast.show('screenshot');
    });

async componentWillUnmount() {
    removeScreenshotListener(this.screenshot);
}
@retyui
Copy link
Contributor

retyui commented Sep 3, 2021

the same problem (Android 11, react-native@0.65)

@retyui
Copy link
Contributor

retyui commented Sep 3, 2021

for my case ContentObserver::onChange(selfChange: Boolean, uri: Uri?, flags: Int) was invoked with:

uri: content://media/external/images/media/59645
flags: 4
path: /storage/emulated/0/DCIM/Screenshots/.pending-1631296636-Screenshot_20210903-205716_DetectScreenshot.jpg

uri: content://media/external/images/media/59645
flags: 8
path: /storage/emulated/0/DCIM/Screenshots/Screenshot_20210903-205716_DetectScreenshot.jpg


uri: content://media/external/images/media/59645
flags: 8
path: /storage/emulated/0/DCIM/Screenshots/Screenshot_20210903-205716_DetectScreenshot.jpg

@retyui
Copy link
Contributor

retyui commented Sep 24, 2021

As foreground you can use a throttle @timothyerwin

@AzizAK
Copy link
Owner

AzizAK commented Mar 16, 2022

the issue has been fixed, now the package saves the latest path and compare it with the upcoming one if it's not matching it will be considered as new screenshots, all the screenshots name with timestamp so it wont be duplicated

@Standin-Alone
Copy link

not working for me

import {
addScreenshotListener,
removeScreenshotListener,
} from 'react-native-detector';

userDidScreenshot = () => {
console.warn('lohin')
};
componentDidMount(){

    addScreenshotListener(this.userDidScreenshot);
}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants