Background time issue for Bluetooth LE app for Iphone 4s

后端 未结 1 382
失恋的感觉
失恋的感觉 2020-12-14 01:53

I am using core-bluetooth framework for my app in Iphone-4s.
This is typically has to be a background app which can run as longer as possible.

Now it is only r

相关标签:
1条回答
  • 2020-12-14 02:24

    I think the problem is simple try to implement you info.plist like my screen:

    enter image description here
    And if you want you can add the function on AppDelegate.m under the didFinishLaunchingWithOptions to enable Bluetooth, AirPlay WiFi and more, this is only a example code, but i think can help you.

    NSError *sessionError = nil;
    [[AVAudioSession sharedInstance] setDelegate:self];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];
    
    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
    
    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
    AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
    
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    

    Hope this can help you.

    0 讨论(0)
提交回复
热议问题