Some apps produce ultrasonic sounds that are supposed to keep dogs away. These apps can also be used to stop an attacking or barking dog. There are options available for both Android and iOS; just search in your phone’s app store.