ios - 对部署目标 8.1 和 XCODE 6.1 使用远程通知
<p><p>我想对部署目标 8.1 和 xcode 6.1 使用远程通知<br/>
我正在使用以下代码</p>
<pre><code>if () {
UIUserNotificationSettings* notificationSettings = ;
[ registerUserNotificationSettings:notificationSettings];
[ registerForRemoteNotifications];
} else {
[ registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
</code></pre>
<p>但它在其他部分向我展示了 <code>deprecated</code> 方法......所以现在我该如何摆脱它......
我尝试的其他代码是:</p>
<p> <img src="/image/p5Uij.png" alt="enter image description here"/> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以像这样忽略不推荐使用的警告:</p>
<pre><code>#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
if () {
UIUserNotificationSettings* notificationSettings = ;
[ registerUserNotificationSettings:notificationSettings];
[ registerForRemoteNotifications];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[ registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#pragma clang diagnostic pop
}
#else
[ registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif
</code></pre>
<p>见 <a href="https://stackoverflow.com/questions/18554449/deprecated-warnings-in-xcode-and-how-to-handle-deprecation" rel="noreferrer noopener nofollow">this post</a> :</p></p>
<p style="font-size: 20px;">关于ios - 对部署目标 8.1 和 XCODE 6.1 使用远程通知,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/28980696/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/28980696/
</a>
</p>
页:
[1]