我已經能夠讓我的iBeacon
應用本地通知推向用戶,而該應用程序會在後臺運行,但由於某種原因,此通知不斷每一秒的間隔重複,UILocalNotification上重複每隔一秒
UILocalNotification *notice = [[UILocalNotification alloc] init];
for (int i=0; i<=1; i++)
{
notice.alertBody = @"We just found some great deals in this location!";
notice.alertAction = @"Open";
[[UIApplication sharedApplication] scheduleLocalNotification:notice];
notice.fireDate = [[NSDate date] dateByAddingTimeInterval:0.2];
}
我只是想,當他們進入該地區,以顯示該通知僅一次給用戶。
'for(int i = 0; i <= 1; i ++)'???真? – matt
你不說這個代碼是如何與你的iBeacon回調綁定的。如果您在回撥範圍內有此設置,則會重複顯示。如果您在監控回調中使用它,則不應無休止地顯示。 – davidgyoung
偉大的答案,謝謝DavidgYoung。我在回調中調用了這個函數,因爲我在邏輯語句中設置了它。 –