仅当应用程序打开并可见时才通过远程通知提醒用户?

alert the user with remote notification only if the app open and visible?

当我向应用程序发送推送通知时,应用程序会收到通知,无论它是打开还是关闭。

我能否仅在应用程序打开且可见时向用户显示通知? 因此,如果该应用 closed/not 可见,我不想提醒用户。

这可能会有帮助

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
UIApplicationState state = [application applicationState];
   if (state == UIApplicationStateBackground)
   {
   //when your app is at background, notification comes here. You can write here code whatever do you want to do notification
   }
}

您还可以控制您的应用何时处于活动或非活动状态,不要忘记添加 UIApplicationDelegate。

是的,它叫做 "silent notification"。

只需更改您的 JSON 有效负载:

{
"aps" : {
    "alert" : "YAP",
    "badge" : 2,
    "sound" : "sound.aiff"
         }
}

{
"aps" : {
    "content-available" : 1,
    "sound" : ""
        }
}

更多信息:

http://www.g8production.com/post/72656082173/ios7-multitasking-silent-notifications

或在这里:

http://developer.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/updating_an_application_in_the_background/