UILocalNotification 事件触发时,我需要暂停播放音乐。
有人建议我使用以下代码。
你可以在这里看到我的帖子
这是代码
- (void)btnSetupNotificationClicked:(id)sender
{
UILocalNotification* pOrderCompletedNotification=[[UILocalNotification alloc] init];
if(pOrderCompletedNotification!=nil)
{
[pOrderCompletedNotification setFireDate:[[NSDate alloc] initWithTimeIntervalSinceNow:5.00]];
// [pOrderCompletedNotification setApplicationIconBadgeNumber:1];
[pOrderCompletedNotification setTimeZone:[NSTimeZone systemTimeZone]];
[pOrderCompletedNotification setSoundName:@"OrderCompleted.m4a"];
[pOrderCompletedNotification setAlertBody:@"Order Completed"];
[pOrderCompletedNotification setAlertAction:nil];
[pOrderCompletedNotification setHasAction:NO];
UIApplication* pApplication=[UIApplication sharedApplication];
if(pApplication!=nil)
{
[pApplication scheduleLocalNotification:pOrderCompletedNotification];
}
else
{
NSLog(@"Application singleton allocation error.");
}
[pOrderCompletedNotification release];
[pApplication release];
}
else
{
NSLog(@"Local notification creation error.");
} // if
}
但我不知道我应该在哪里self.player pause
用这些方法写我的代码?我需要在 AppDelegate 中连接以下代码吗?
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"EVENT from Notification");
}
我该怎么做?