2014-12-24 3 views
0

iOS 8을 사용하여 iOS 앱에 알림을 만들었습니다. UIUserNotificationTypeSound이 등록되어 있고 기본 소리 이름이 지정되었지만 알림이 제대로 표시되지만 소리가 재생되지 않습니다. 알림을 받으면 어떻게 사운드를 재생할 수 있습니까? UIUserNotificationTypeSoundiOS 알림 소리가 재생되지 않음

등록

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]] return YES; } 

설정 기본 사운드 이름

localNotif.soundName = UILocalNotificationDefaultSoundName; 

답변

0

내가 코드 를 테스트하지 않았습니다하지만 내 코드를 비교, 당신이 [application registerForRemoteNotifications]; 메소드를 호출하지 않습니다 발견

if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
{ 
    // iOS 8 Notifications 
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 

    [application registerForRemoteNotifications]; 
} 

시도해보십시오. 도움이 될 것입니다. didRegisterForRemoteNotificationsWithDeviceToken을 : 나 응용 프로그램 : didFailToRegisterForRemoteNotificationsWithError : 응용 프로그램 위임에 호출 할

+0

난 당신이 알림 응용 프로그램 중 하나가 발생합니다이 호출 @Noor 백엔드 – Noor

+0

에서 오는 개체가 경우에만 registerForRemoteNotifications 메서드를 호출해야한다 생각합니다. 참고 :이 콜백은 응용 프로그램이 registerUserNotificationSettings :로 사용자 알림을 성공적으로 등록한 경우에만 또는 백그라운드 응용 프로그램 새로 고침이 활성화 된 경우에만 수행됩니다. – Janmenjaya

+0

나는 registerUserNotificationSettings가 성공적으로 설정되었다고 생각한다. 왜냐하면 설정에서 앱의 알림이 켜지고 꺼질 수 있는데 이는 성공적으로 등록되었음을 의미한다. 맞습니까? – Noor

관련 문제