我正在使用以下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
pushcome=NO;
pushcome=[self registerForPushNotification:launchOptions];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
return YES;
}
以下代码用于接收推送:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
NSLog(@"BACK GROUND MODE PUSH");
if([userInfo[@"aps"][@"content-available"] intValue]== 1) //it's the silent notification
{
[self saveInUserDefault];
stkaudioPlayer = [[STKAudioPlayer alloc]init]; //player initialize
//Save audio url
NSString *str= [userInfo valueForKey:@"AudioURL"];
[[NSUserDefaults standardUserDefaults]setObject:str forKey:@"forUrl"];
[[NSUserDefaults standardUserDefaults] synchronize];
// for Playing an audio using 'Avplayer' ==>
NSString *finalUrl = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] stringForKey:@"forUrl"]];
NSURL *url = [NSURL URLWithString:finalUrl];
playerItem = [AVPlayerItem playerItemWithURL:url];
player = [AVPlayer playerWithPlayerItem:playerItem];
player = [AVPlayer playerWithURL:url];
[player play];
// <===
completionHandler(UIBackgroundFetchResultNewData);
NSLog(@"==Hi, I am from silent Notification ========%@",[[NSUserDefaults standardUserDefaults] stringForKey:@"forUrl"]);
return;
}
else
{
NSLog(@"User ... %@",userInfo);
return;
}
}
我收到以下错误: -
[0x37fd8000]&gt; aurioc&gt; 807:失败:'!int'(启用2,outf&lt; 2 ch,44100 Hz,Int16,inter&gt; inf&lt; 2 ch,0 Hz,Float32,非inter&gt;
答案 0 :(得分:0)
用于推送通知声音 您需要使用此代码
Private Sub CommandButtonRemoveSelectedProjects_Click()
Dim selectioncount As Long
selectioncount = ListBoxProjectsToRemove.Selected(i)
Set TxtRng = ActiveWorkbook.Sheets("VBA_Data").Range("AY1")
For i = 0 To ListBoxProjectsToRemove.ListCount - 1
If ListBoxProjectsToRemove.Selected(i) Then
SelectedItemText = ListBoxProjectsToRemove.List(i)
End If
Next i
TxtRng.Value = SelectedItemText
End Sub