手机编程,发送消息到消息中心

首先在应用上添加TNotificationCenter控件,然后添加下面的函数就行了


procedure TMainFrm.SendMsgToScreen(Msg: String);

var
MyNotification: TNotification;
begin
//通过消息中心创建消息
MyNotification := NotificationCenter1.CreateNotification;
try
    //设置消息的名称
    MyNotification.Name := 'Schedule Notification';
    //设置消息的内容
    MyNotification.AlertBody := 'Schedule Notification:' + Msg;
    //设置图标标号
    MyNotification.Number := 18;

    //设置10秒后触发消息
    MyNotification.FireDate := Now + EncodeTime(0, 0, 10, 0);
    //将消息提交消息中心,并于指定时间触发,直接发送用PresentNotification
    NotificationCenter1.ScheduleNotification(MyNotification);
finally
    //释放消息接口
    MyNotification.DisposeOf;
end;
end;

调用方法
            SendMsgToScreen('发送时间:'+LItem.Data['DATETIME'].AsString
                +' 发送到:'+LItem.Data['Tel'].AsString
                +' 姓名:'+LItem.Data['Name'].AsString
                +' 内容:'+LItem.Data['CONTENT'].AsString);
原文地址:https://www.cnblogs.com/zhenfei/p/4070294.html