简体   繁体   English

如何将推送主题设置为推送通知的标题?

[英]How to set push subject as the title for push notification?

Is there any possibilities of setting push subject as the title in push notification? 是否有可能将推送主题设置为推送通知中的标题? I'm getting app name as the subject and description is same as given in the push. 我将应用程序名称作为主题,描述与推送中给出的相同。 I want to change the title of the push. 我想改变推送的标题。
Is this possible in iOS? 这在iOS中可行吗? I hope it is possible in android. 我希望在android中有可能。

I just tested this on an iPhone 6s running iOS 9.1, and here's what I found: If the title field is provided as part of the alert dictionary, the notification on the lock screen will still show the bundle name. 我刚刚在运行iOS 9.1的iPhone 6s上测试了这个,这就是我发现的:如果标题字段是作为警报字典的一部分提供的,锁定屏幕上的通知仍将显示包名称。 However, when viewing the same notification in Notification Center (accessed by swiping down from the top edge), the title is used in place of the app/bundle name. 但是,在通知中心查看相同的通知(通过从顶部边缘向下滑动访问)时,将使用标题代替应用程序/包名称。

When no title field is provided as part of the alert dictionary, the bundle name is displayed in both the lock screen and the Notification Center. 如果没有提供标题字段作为警报字典的一部分,则包名称将显示在锁定屏幕和通知中心中。

As of 2015, Apple has started using a title attribute but only seems to use when displaying a notification on the Apple Watch. 截至2015年,Apple已开始使用title属性,但似乎只在Apple Watch上显示通知时使用。

The title string used in the short look provides a brief indication of the intent of the notification. 简短外观中使用的标题字符串提供了通知意图的简要说明。 For local notifications, you specify this string using the alertTitle property of the UILocalNotification object. 对于本地通知,您可以使用UILocalNotification对象的alertTitle属性指定此字符串。 For remote notifications, add the title key to the alert dictionary inside the payload 对于远程通知,将标题键添加到有效负载内的警报字典中

This might indicate that it will be used also on the iPhone later on. 这可能表明它稍后也将在iPhone上使用。

Source: https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html 资料来源: https//developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html

Here's an example JSON payload: https://gist.github.com/edwardmp/2295364f068b24084e67561c8e5c2944 以下是JSON有效负载的示例: https//gist.github.com/edwardmp/2295364f068b24084e67561c8e5c2944

Edit: As of iOS 9 this started working on iPhone and iPad as well :) I do note that this appears to only be displayed in the notification center and not on the lock screen. 编辑:从iOS 9开始,这也开始在iPhone和iPad上运行:)我注意到这似乎只显示在通知中心而不是锁定屏幕上。

You can't change the title. 你不能改变标题。 It's always the application name. 它始终是应用程序名称。

Suppose you are playing chess with your friend online. 假设你在网上与你的朋友下棋。 While you are in the chess app, your friend's moves appear on the board right away. 当你在国际象棋应用程序中时,你朋友的动作会立即出现在棋盘上。 When you switch to another app—for example, to read email while your friend decides where to move—the app needs a way to notify you when your friend moves. 当您切换到另一个应用程序时 - 例如,当您的朋友决定移动时,阅读电子邮件 - 该应用程序需要一种在您的朋友移动时通知您的方式。 This is a perfect use case for a push notification—something changed outside of the app that is of interest to the user. 这是推送通知的完美用例 - 在用户感兴趣的应用程序之外进行了更改。

The provider for the chess application learns about this move and, seeing that the chess application on your device is no longer connected, sends a push notification to Apple Push Notification service (APNs). 国际象棋应用程序的提供者了解此移动,并且看到您的设备上的国际象棋应用程序不再连接,向Apple推送通知服务(APN)发送推送通知。 Almost immediately, your device—or more precisely, the operating system on your device—receives the notification over the Wi-Fi or cellular connection from APNs. 您的设备 - 或者更确切地说,设备上的操作系统 - 几乎立即通过Wi-Fi或APN的蜂窝连接接收通知。 Because your chess application is not currently running, iOS displays an alert similar to Figure 1-1. 由于您的国际象棋应用程序当前未运行,iOS会显示类似于图1-1的警报。 The message consists of the application name , a short message, and (in this case) two buttons: Close and View. 该消息由应用程序名称 ,短消息和(在本例中)两个按钮组成:关闭和查看。 The button on the right is called the action button and its default title is “View”. 右侧的按钮称为操作按钮,其默认标题为“查看”。 An application can customize the title of the action button and can internationalize the button title and the message so that they are in the user's preferred language. 应用程序可以自定义操作按钮的标题,并可以将按钮标题和消息国际化,以便它们是用户的首选语言。

You can refer your client to the official APNS docs to convince them that's the way it is. 您可以将您的客户推荐给官方APNS文档,以说服他们就是这样。

Yes, you can add a title property since iOS 8.2. 是的,您可以在iOS 8.2之后添加title属性。

A short string describing the purpose of the notification. 描述通知目的的短字符串。 Apple Watch displays this string as part of the notification interface. Apple Watch将此字符串显示为通知界面的一部分。 This string is displayed only briefly and should be crafted so that it can be understood quickly. 此字符串仅短暂显示,应精心设计,以便快速理解。 This key was added in iOS 8.2. 此密钥已在iOS 8.2中添加。

Check the Apple Document - The Remote Notification Payload 检查Apple文档 - 远程通知有效负载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM