#if objc
@import MediaPlayer;
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
- (NSArray*) getGravity: (CMMotionManager*) manager
{
CMDeviceMotion *motion = manager.deviceMotion;
CMAcceleration acc = motion.gravity;
return @[@(acc.x), @(acc.y), @(acc.z)];
}
- (void)startMotion:(CMMotionManager*)manager
{
[manager startDeviceMotionUpdatesUsingReferenceFrame: CMAttitudeReferenceFrameXArbitraryCorrectedZVertical];
}
- (void)setAudioSession {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&err];
if (success) {
success = [audioSession setActive:YES error:&err];
success = [audioSession setPreferredSampleRate:4096 error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}
if (!success)
[NSException raise:@"" format:@"Error setting audio session: %@", err];
}
#End If
#if objc
@end
@interface B4ILocationManager (beacon)
@end
@implementation B4ILocationManager (beacon)
- (void)locationManager:(CLLocationManager *)manager
didRangeBeacons:(NSArray*)beacons
inRegion:(CLBeaconRegion *)region {
If (beacons.count > 0) {
[B4IObjectWrapper raiseEvent:self :@"_didrangebeacons:"
:@[[B4IObjectWrapper createWrapper:[B4IList new] object:beacons]]];
}
}
#End If