Lập trình Windows Phone - Module 4 – Bài 5: Push Notification

Giới thiệu

Kiến trúc của Push Notifications

Toast Notifications

Tile Notifications

Raw Notifications

 

pptx12 trang | Chia sẻ: Mr Hưng | Lượt xem: 827 | Lượt tải: 0download
Nội dung tài liệu Lập trình Windows Phone - Module 4 – Bài 5: Push Notification, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
Lập trình Windows Phone Module 4 – Bài 5: Push NotificationGV Biên soạn: Trần Duy ThanhNội dungGiới thiệuKiến trúc của Push NotificationsToast NotificationsTile NotificationsRaw Notifications1. Giới thiệuMicrosoft đã đưa ra một kênh mạnh mẽ cho các lập trình viên gửi và cập nhật thông tin cho ứng dụng mobile từ dịch vụ web (web service đã học trước đó), tính năng này được gọi là Push Notification Service.2. Kiến trúc của Push Notifications2. Kiến trúc của Push NotificationsỨng dụng của bạn sẽ request một push nofitication URI từ Push Client ServicePush Client Service sẽ làm việc với Microsoft Push Notification Service(MPNS), và sau đó MPNS sẽ gửi về cho Push Client Service một notification URI.Push Client Service cấp phát cho ứng dụng của bạn notification URI vừa trả về.Khi đã được cấp phát notification URI thì ứng dụng của bạn đã có thể trực tiếp làm việc với Service của bạn.Khi phía Service có thông tin để gửi tới ứng dụng của bạn, thì trước tiên Service sẽ gửi thông tin tới MPNS thông qua notification URI của ứng dụng.Cuối cùng là thông báo sẽ gửi tới ứng dụng của bạn.3. Toast NotificationsHiển thị thông báo ở trên topcủa màn hình điện thoại, giống như các thông báo khi có tin nhắn, hay email mới:4. Tile NotificationsHiển thị thông tin phía các Huc LiveTile của ứng dụng (khi ứng dụng của bạn được Pin vào Start Screen). 5. Raw NotificationsThường dùng để nhận mẩu tin khi đang chạy ứng dụng, có thể là Text File, Image file Raw Notifications yêu cầu ứng dụng phải đang ở trong chế độ Foreground lifetime.5. Raw NotificationsĐể thực hiển Push hình ảnh từ Server tới Client:Tại Server: MemoryStream ms=new MemoryStream(); pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); sendNotificationRequest.ContentLength = ms.Length; using (Stream requestStream = sendNotificationRequest.GetRequestStream()) { requestStream.Write(ms.ToArray(), 0, (int)ms.Length); }5. Raw NotificationsTại mobile client:void httpChannel_HttpNotificationReceived(object sender, HttpNotificationEventArgs e){ if (e.Notification.Body != null && e.Notification.Headers != null) { Dispatcher.BeginInvoke(() => { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(e.Notification.Body); myimage.Source = bitmapImage; }); }}Bảng so sánhPN TypeMust Application Be Running in Foreground?Must Application Tile Be Pinned to Start Screen?UseToastNoNoDùng cho các trường hợp khẩn cấp và thời gian nhạy cảm: Ví dụ cảnh báo sấm chớp, bãoTileNoYesDùng để cập nhật: Ví dụ chư đếm số email mới, đếm ố người comment trên Facebook RawYesNoDữ liệu liên tục (Twitter client, stock ticker)Thảo luận

Các file đính kèm theo tài liệu này:

  • pptxwp_module4_bai5_push_notification_6746.pptx
Tài liệu liên quan