我正在使用CrossPlateForm
技術使用xamarine創建Android和IOS應用程序,我想在應用程序處於睡眠模式時發送推送通知, this是我的方法如何僅在應用程序處於睡眠模式時從便攜式項目調用pushNotification
public void pushNotifications(int count)
{
Notification.Builder builder = new Notification.Builder(this)
.SetContentTitle("new Messages")
.SetContentText("Hello World! This is my first notification!")
.SetSmallIcon(Resource.Drawable.icon);
// Instantiate the Inbox style:
Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
// Set the title and text of the notification:
builder.SetContentTitle(count+" new messages");
//builder.SetContentText("[email protected]");
// Plug this style into the builder:
builder.SetStyle(inboxStyle);
// Build the notification:
Notification notification = builder.Build();
// Get the notification manager:
NotificationManager notificationManager =
GetSystemService(Context.NotificationService) as NotificationManager;
// Publish the notification:
const int notificationId = 0;
notificationManager.Notify(notificationId, notification);
}
計數將來自我在便攜式項目寫道,當我試圖寫在便攜式項目Notification.Builder
我無法訪問Notification
命名空間pushNotification
方法的服務。我想在portable
項目中觸發一個方法,只要應用程序使用睡眠模式並使用pushNotification
顯示計數,或者是他們的任何替代方式來執行此操作?
你是什麼意思「睡眠模式」?是[this](https://android.stackexchange.com/questions/95625/what-is-androids-sleep-mode)? –