我正在使用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)? –