IOS 7 判断 "Show in Notification Center"是否被禁用
<p><p>我正在使用以下代码来确定用户是否启用了警报通知</p>
<pre><code>UIRemoteNotificationType notificationType =[ enabledRemoteNotificationTypes];
if (!(notificationType & UIRemoteNotificationTypeAlert))
{
}
</code></pre>
<p>当我设置时</p>
<blockquote>
<p>Settings -> Notifications -> Appname -> "Show in Notification
Center" to YES</p>
</blockquote>
<p>并选择警报类型以通知我得到 UIRemoteNotificationTypeAlert 的通知类型</p>
<p>当我设置时</p>
<blockquote>
<p>Settings -> Notifications -> Appname -> "Show in Notification
Center" to NO</p>
</blockquote>
<p>我仍然收到通知类型的 UIRemoteNotificationTypeAlert。有没有办法判断是否</p>
<blockquote>
<p>"Show in Notification Center"</p>
</blockquote>
<p>设置为否?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>简单的答案 - 这不能以编程方式完成。 </p>
<p>你可以这样称呼:</p>
<pre><code>UIRemoteNotificationType types = .enabledRemoteNotificationTypes;
</code></pre>
<p>在您的 <code>UIRemoteNotificationType</code> 中给出以下枚举:</p>
<pre><code>typedef enum
{
UIRemoteNotificationTypeNone = 0,
UIRemoteNotificationTypeBadge = 1 << 0,
UIRemoteNotificationTypeSound = 1 << 1,
UIRemoteNotificationTypeAlert = 1 << 2,
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
}
</code></pre>
<p>因此您可以知道用户启用的通知类型,但不知道用户是否为您的应用启用或禁用了通知中心。</p></p>
<p style="font-size: 20px;">关于IOS 7 判断"Show in Notification Center"是否被禁用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32887812/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32887812/
</a>
</p>
页:
[1]