@@ -155,10 +155,14 @@ class RNInCallManager: NSObject, AVAudioPlayerDelegate {
155155 print ( " startProximitySensor() " )
156156 self . currentDevice. proximityMonitoringEnabled = true
157157
158+ //self.stopObserve(self, name: UIDeviceProximityStateDidChangeNotification, object: self.currentDevice)
158159 self . startObserve ( UIDeviceProximityStateDidChangeNotification, object: self . currentDevice, queue: nil ) { notification in
159160 let state : Bool = self . currentDevice. proximityState
160- print ( " Proximity Changed. isNear: \( state) " )
161- self . bridge. eventDispatcher. sendDeviceEventWithName ( " Proximity " , body: [ " isNear " : state] )
161+ if state != self . proximityIsNear {
162+ print ( " Proximity Changed. isNear: \( state) " )
163+ self . proximityIsNear = state
164+ self . bridge. eventDispatcher. sendDeviceEventWithName ( " Proximity " , body: [ " isNear " : state] )
165+ }
162166 }
163167
164168 self . isProximityRegistered = true
@@ -328,8 +332,10 @@ class RNInCallManager: NSObject, AVAudioPlayerDelegate {
328332 func getRingbackUri( _type: String ) -> NSURL ? {
329333 let fileBundle : String = " incallmanager_ringback "
330334 let fileBundleExt : String = " mp3 "
331- let fileSysWithExt : String = " vc~ringing.caf "
332- let fileSysPath : String = " /System/Library/Audio/UISounds "
335+ //let fileSysWithExt: String = "vc~ringing.caf" // --- ringtone of facetine, but can't play it.
336+ //let fileSysPath: String = "/System/Library/Audio/UISounds"
337+ let fileSysWithExt : String = " Marimba.m4r "
338+ let fileSysPath : String = " /Library/Ringtones "
333339 let type = ( _type == " " || _type == " _DEFAULT_ " ? fileSysWithExt : _type) // --- you can't get default user perfrence sound in ios
334340 return self . getAudioUri ( type, fileBundle, fileBundleExt, fileSysWithExt, fileSysPath, & self . bundleRingbackUri, & self . defaultRingbackUri)
335341 }
@@ -376,15 +382,18 @@ class RNInCallManager: NSObject, AVAudioPlayerDelegate {
376382 }
377383
378384 func getSysFileUri( target: String ) -> NSURL ? {
379- let fileManager : NSFileManager = NSFileManager ( )
380- let url : NSURL = NSURL ( fileURLWithPath: target, isDirectory: false )
381- var isTargetDirectory : ObjCBool = ObjCBool ( false )
382- if fileManager. fileExistsAtPath ( url. path!, isDirectory: & isTargetDirectory) {
383- if !isTargetDirectory {
384- //print("\(url.URLByDeletingPathExtension?.lastPathComponent)")
385- return url
385+ if let url: NSURL ? = NSURL ( fileURLWithPath: target, isDirectory: false ) {
386+ if let path = url? . path {
387+ let fileManager : NSFileManager = NSFileManager ( )
388+ var isTargetDirectory : ObjCBool = ObjCBool ( false )
389+ if fileManager. fileExistsAtPath ( path, isDirectory: & isTargetDirectory) {
390+ if !isTargetDirectory {
391+ return url
392+ }
393+ }
386394 }
387395 }
396+ print ( " can not get url for \( target) " )
388397 return nil
389398 }
390399
@@ -394,7 +403,8 @@ class RNInCallManager: NSObject, AVAudioPlayerDelegate {
394403 let filename = player. url? . URLByDeletingPathExtension? . lastPathComponent
395404 if filename == self . bundleBusytoneUri? . URLByDeletingPathExtension? . lastPathComponent
396405 || filename == self . defaultBusytoneUri? . URLByDeletingPathExtension? . lastPathComponent {
397- self . stopBusytone ( )
406+ //self.stopBusytone()
407+ print ( " busytone finished, invoke stop() " )
398408 self . stop ( " " )
399409 }
400410 print ( " finished playing: \( filename) " )
0 commit comments