Posts

Post not yet marked as solved
0 Replies
296 Views
Hello, I'm noob in objective-c and xcode.I need to send sound category properly so user will be able to hear a background sound while Unity3d application is running.I'm try to override method willFinishLaunchingWithOptions but it is not working.Can somebody tell me what am I doing wrong?//-----------------------------------------------------#import "OverrideUnityAppController.h"#import <Foundation/Foundation.h>#import <AVFoundation/AVFoundation.h>#include "PluginBase/AppDelegateListener.h"@implementation OverrideUnityAppController- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation{ NSMutableArray* keys = [NSMutableArray arrayWithCapacity:3]; NSMutableArray* values = [NSMutableArray arrayWithCapacity:3]; auto addItem = [&](NSString* key, id value) { [keys addObject:key]; if (value == nil) { [values addObject:[NSNull null]]; } else { [values addObject:value]; } }; addItem(@"url", url); addItem(@"sourceApplication", sourceApplication); addItem(@"annotation", annotation); NSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys]; AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); return YES;}- (BOOL)application:(UIApplication*)application willFinishLaunchingWithOptions:(NSDictionary*)launchOptions{ NSLog(@"Setting AVAudioSession Category to AVAudioSessionCategoryAmbient"); [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; return YES;}@endIMPL_APP_CONTROLLER_SUBCLASS(OverrideUnityAppController)//-----------------------------------------------and header file://-----------------------------------------------#import "UnityAppController.h"@interface OverrideUnityAppController : UnityAppController- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation;- (BOOL)application:(UIApplication*)application willFinishLaunchingWithOptions : (NSDictionary*)launchOptions;@end
Posted
by ferzin.
Last updated
.