2013-04-11 71 views
0

當用戶通過地理圍欄區域輸入區域時,我發出了本地通知。但是當我按Home按鈕查看本地通知時,它確實顯示,但沒有聲音。我試圖在mac設置中禁用並啓用「播放用戶界面聲音..」,關閉並重新打開xcode,清理項目並最終重新啓動mac。沒有工作.. 我錯過了什麼?UILocalNotification聲音

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { 
    NSLog(@"Entered Region - %@", region.identifier); 
    UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
    [localNotification setAlertBody:@"You are about to enter.."]; 
    [localNotification setSoundName:@"Voicemail.caf"]; 

    UIApplication *application = [UIApplication sharedApplication]; 
    [application presentLocalNotificationNow:localNotification]; 
} 
+0

你在哪裏開啓了UILocalNotification? – 2013-12-03 06:44:32

+0

您可以編寫代碼如何通過geofencing管理用戶輸入區域嗎? – 2013-12-03 07:03:05

+0

您好我有一個地理圍欄要求是新的IOS加州大學請分享您的示例代碼,以在我們的應用程序中添加地理圍欄 – sabir 2014-02-26 08:44:14

回答

0

轉到Build Phases並將您的.caf文件添加到Copy Bundle Resources。它幫助我

1

在這裏,你可以通過你的聲音文件的名稱

UILocalNotification *notifThreshold = [[UILocalNotification alloc]init]; 
    if(notifThreshold) 
    { 
     notifThreshold.alertBody = statusMsg; 
     notifThreshold.alertAction= @"Open"; 
     notifThreshold.userInfo = userInfo; 
     notifThreshold.soundName = UILocalNotificationDefaultSoundName; 

     UIApplicationState state = [[UIApplication sharedApplication] applicationState]; 
     if (state == UIApplicationStateBackground) 
     { 

     notifThreshold.applicationIconBadgeNumber = [[UIApplication sharedApplication] 
                applicationIconBadgeNumber]+1; 
     } 
     [[UIApplication sharedApplication] presentLocalNotificationNow:notifThreshold]; 
    } 
0

請確保在通知中心的應用程序的聲音被啓用,而不是使用蓋延伸嘗試使用WAV擴展名,例如「 beep.wav「或」Default.wav「...

相關問題