Mavericks iOS 模拟器中的推送通知 [英] Push Notifications in Mavericks iOS Simulator

查看:39
本文介绍了Mavericks iOS 模拟器中的推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到任何关于此的信息,而且我从未对推送通知做过任何事情(但我模糊地知道它们是如何工作的).在 Mavericks 中,既然 OS X 可以接收来自各种事物(例如网站)的推送通知,那么 iPhone Simulator 可以接收推送通知吗?我在 2013 年年中和更早的时候找到了很多回答说不",但所有这些都已经过时了,因为小牛队最近刚刚发布了新的推送功能.

I can't find anything about this, and I have never done anything with push notifications (but I know vaguely how they work). In Mavericks, now that OS X can receive push notifications from various things like websites, can iPhone Simulator receive push notifications? I've found plenty of answers from mid-2013 and earlier saying "no", but all of them are outdated because Mavericks was just recently released with its new push features.

我即将开始为学校项目开发一个应用程序,该应用程序应该使用推送通知,除非我想便宜点并且只轮询服务器.我知道您需要一个 iOS 开发者帐户才能使用推送通知,但如果我可以在我的计算机上进行测试,那会让我的生活变得更轻松.

I'm about to start working on an app for a school project that should use push notifications unless I want to be cheap and just poll the server. I understand that you NEED an iOS developer account to use push notifications, but it would make my life a lot easier if I could test on my computer.

推荐答案

是啊!!随着XCode 11.4 的发布,现在也可以在模拟器中接收推送通知了.Apple 的最新版本说,

Yeahhh!! With the release of XCode 11.4, Now it is possible to receive Push notification in Simulator too. Apple's latest release says,

Simulator 支持模拟远程推送通知,包括后台内容获取通知.

Simulator supports simulating remote push notifications, including background content fetch notifications.

在模拟器中,将 APNs 文件拖放到目标模拟器上.该文件必须是具有有效 Apple 推送通知的 JSON 文件服务负载,包括aps"键.

In Simulator, drag and drop an APNs file onto the target simulator. The file must be a JSON file with a valid Apple Push Notification Service payload, including the "aps" key.

它还必须包含一个顶级的模拟器目标包"匹配目标应用程序包标识符的字符串值.

It must also contain a top-level "Simulator Target Bundle" with a string value matching the target application‘s bundle identifier.

参考链接:https://developer.apple.com/documentation/xcode_release_notes/xcode_11_4_beta_release_notes

示例有效负载文件,

{
    "Simulator Target Bundle": "com.yourOrganization.appName",
    "aps": {
        "alert": "This is a test notification!",
        "badge": 5,
        "sound": "default"
    }
}

@note:在上述有效负载的模拟器目标捆绑包"中提及您的应用程序的捆绑包标识符.

@note: mention your application's Bundle Identifier in "Simulator Target Bundle" in the above Payload.

将上面的 json 文件拖放到目标模拟器上将显示通知并设置徽章.

Dragging and dropping above json file onto the target simulator will present the notification and set the badge.

这篇关于Mavericks iOS 模拟器中的推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆