Git Product home page Git Product logo

react-native-silent-listener's People

Stargazers

 avatar  avatar

Watchers

 avatar

react-native-silent-listener's Issues

Fix: startup silent status detection

Hi there, I would like to contribute to the project, I've already made the changes in local and if you want I can push the patch for PR review. Basically I've just added a check for an initialValue reported and paused/resumed Mute on the startObserving/stopObserving methods. This allows to have a more trusted detection for startup.

Here below is the diff:

     var previousValue: Bool = false
     var hasListeners: Bool = false
-    
+    var initialValueReported: Bool = false
+
     override init() {
       super.init()
-      
+
       Mute.shared.checkInterval = 2.0
       Mute.shared.alwaysNotify = true
-      
+      Mute.shared.isPaused = true
       Mute.shared.notify = onNotify
     }
-    
+
     @objc func setInterval(_ newInterval: NSNumber) {
         Mute.shared.checkInterval = Double(newInterval);
     }
-    
+
     func onNotify(_ newVal: Bool) {
-      if previousValue == newVal {
-        return
-      }
-      
-      previousValue = newVal
       if hasListeners {
+
+        if previousValue == newVal && self.initialValueReported {
+          return
+        }
+
+        self.initialValueReported = true
+        previousValue = newVal
+
         sendEvent(withName: "onSilentChange", body: newVal)
+      
       }
     }
-    
+
     override func startObserving() {
       self.hasListeners = true
+      Mute.shared.isPaused = false
     }
-    
+
     override func stopObserving() {
       self.hasListeners = false;
+      Mute.shared.isPaused = true
     }
 }

Pod install error

Hi!

I have an issue, when run pod install

  • react-native-silent-listener does not specify a Swift version and none of the targets (XXX) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

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.