当我的应用程序位于前台时,会出现一个警告。如何在接收推送通知时阻止这种情况出现?
答案 0 :(得分:7)
在didFinishLaunchingWithOptions
的{{1}}方法中,您必须添加AppDelegate
kOSSettingsKeyInAppAlerts = NO
答案 1 :(得分:6)
对于Swift 3.0
<table>
<?php
$table_name = "candle_number";
$data = $wpdb->get_results( "SELECT * FROM `{$table_name}` WHERE `userid` = '{$current_user->ID}';" );
$i=1;/* to what purpose?? */
foreach( $data as $rs ){
echo "
<tr>
<td><strong>{$rs->dname}</strong></td>
<td>{$rs->dateenglish}<br>{$rs->datehebrew}</td>
<td><!-- /* Notice the various dataset attributes here */ -->
<a href='#' data-name='{$rs->dname}' data-dod='{$rs->dateenglish}' data-hdod='{$rs->datehebrew}'>
<img width=50 height=50 src='http://www.mountsinaiparks.org/digital-yahrzeit/wp-content/themes/yahrzeit-theme/bootstrap/images/Candle01.gif' class='img-responsive candle' alt='Yahrzeit Candle' style='margin:auto !important;' />
</a><br>
<p style='text-align:center !important; margin:-10px 0 0 0 !important; padding:0; line-height:7px !important;'><span style='color: #f26522 !important; font-size:10px !important; font-weight:700 !important;'>CLICK TO LIGHT</span></p>
</td>
<td><a href='delete.php?id=$id'>Delete</a></td>
</tr>";
$i++;
}
?>
</table>
答案 2 :(得分:3)
默认情况下,当应用程序处于焦点时,OneSignal会将通知显示为警告对话框。要将kOSSettingsKeyInFocusDisplayOption
的值OSNotificationDisplayTypeNotification
或OSNotificationDisplayTypeNone
更改为initWithLaunchOptions上的设置。
答案 3 :(得分:1)
我是这样实现的。在AppDelegate didFinishLaunchingWithOptions
中添加以下代码OneSignal.inFocusDisplayType = OSNotificationDisplayType.none
在
的最后一行func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
OneSignal.inFocusDisplayType = OSNotificationDisplayType.none
return true }
我们有这3个选项
public enum OSNotificationDisplayType : UInt {
/*Notification is silent, or app is in focus but InAppAlertNotifications are disabled*/
case none
/*Default UIAlertView display*/
case inAppAlert
/*iOS native notification display*/
case notification
}