2014-12-19 3 views
3

V1 용 내 앱에서 푸시 알림을 사용할 수 있습니다. 그러나 푸시 알림 장치를 등록하는 동안 플래그 UIUserNotificationTypeSound을 사용하지 않았습니다.iOS 8 푸시 알림 사운드가이 특정 케이스에서 작동하지 않습니다.

푸시 알림을 보내면 예상했던 소리가 들리지 않습니다. 나중에이 플래그를 추가하면 사운드를 새로 설치 한 경우에만 재생하고 V1을 다시 등록하더라도 충실한 사용자는 재생하지 않습니다.

사운드는 설정에서 기본적으로 꺼져 있습니다.

프로그래밍 방식으로이 문제를 해결할 수 있습니까?

+1

:

여기에 엑스 코드 (5)와 엑스 코드 (6)

헤더 모두에서 작동합니다 당신을 위해 깨끗한 인터페이스 뒤에이 논리를 숨길 수 UIApplication의 범주입니다. "충성도가 높은 사용자"에게 다시 사용하도록 요청해야합니다. 다행히도 이것보다 나은 방법이 있습니다. – Raptor

답변

3

확인이 자습서, 그것은

아이폰 OS 2015년 1월 8일

https://documentation.appboy.com/Enabling_Message_Channels/Push_Notifications/iOS의 오늘 2 일 대한의 비 호환 방법으로 통지 등록을 변경했습니다. iOS 7 및 8을 지원해야하지만 (8 SDK를 사용하여 빌드 된 앱은 허용되지 않음) 필요한 버전의 셀렉터가 있는지 확인하고 실행 버전에 맞게 조건부로 호출 할 수 있습니다. 이전에 비슷한 사건을 경험

//Call these from your application code for both iOS 7 and 8 
//put this in the public header 
@interface UIApplication (RemoteNotifications) 

- (BOOL)pushNotificationsEnabled; 
- (void)registerForPushNotifications; 

@end 
Implementation: 

//these declarations are to quiet the compiler when using 7.x SDK 
//put this interface in the implementation file of this category, so they are 
//not visible to any other code. 
@interface NSObject (IOS8) 

- (BOOL)isRegisteredForRemoteNotifications; 
- (void)registerForRemoteNotifications; 

+ (id)settingsForTypes:(NSUInteger)types categories:(NSSet*)categories; 
- (void)registerUserNotificationSettings:(id)settings; 

@end 

@implementation UIApplication (RemoteNotifications) 

- (BOOL)pushNotificationsEnabled 
{ 
    if ([self respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
    { 
     return [self isRegisteredForRemoteNotifications]; 
    } 
    else 
    { 
     return ([self enabledRemoteNotificationTypes] & UIRemoteNotificationTypeAlert); 
    } 
} 

- (void)registerForPushNotifications 
{ 
    if ([self respondsToSelector:@selector(registerForRemoteNotifications)]) 
    { 
     [self registerForRemoteNotifications]; 

     Class uiUserNotificationSettings = NSClassFromString(@"UIUserNotificationSettings"); 

     //If you want to add other capabilities than just banner alerts, you'll need to grab their declarations from the iOS 8 SDK and define them in the same way. 
     NSUInteger UIUserNotificationTypeAlert = 1 << 2; 

     id settings = [uiUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert categories:[NSSet set]];    
     [self registerUserNotificationSettings:settings]; 

    } 
    else 
    { 
     [self registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert]; 
    } 
} 

@end 
+0

불만을 호소하는 고객이있는 경우이 방법은 훌륭한 솔루션이며 실제로 혜택을받을 가치가 있지만 수정본을 제출할 때까지 설정 앱에 들어가서 소리를 활성화 할 수도 있습니다. 설정 -> 알림 -> 응용 프로그램 이름 -> 소리 –

+0

하이, 같은 문제에 직면했지만 내 프로젝트에서이 코드를 사용할 위치를 모르므로이 코드로이 문제를 해결할 수 없습니다. 설명해 주시겠습니까? – Manimaran

1

다음은 가능한 두 가지 해결책을 제시 한 것입니다.

옵션 1 : 방금 ​​설치 한 것처럼 작동하도록 모든 계정을 재설정하십시오. 가능한 방법 : 코어 데이터, .plist 파일 등

옵션 2 : 당신이 새로 설치 한 것처럼 응용 프로그램의 모든 데이터를 재설정하여이 문제를 해결 앱의 업데이트를 보낼 경우, 만들기 모든 사용자의 소리 재생. 핵심 데이터를 사용하여 프로그래밍 방식으로 간단히 재설정하십시오.