Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Windows Azure > Windows Azure (Mobile Services) and Windows Phone (WP8) > ตอนที่ 9 : การทำ Push Notifications in Mobile Services ด้วย Windows Phone



Clound SSD Virtual Server

ตอนที่ 9 : การทำ Push Notifications in Mobile Services ด้วย Windows Phone

ตอนที่ 9 : การทำ Push Notifications in Mobile Services ด้วย Windows Phone การทำ Push Notification เป็นความสามารถหนึ่งของ Mobile Services ในการ Push Alert แจ้งไปยังเครื่อง Windows Phone Client ที่ติดตั้ง App ที่เราเขียนขึ้น และถ้าเราใช้ Windows Phone กับ Mobile Services สามารถใช้บริการของ Microsoft Push Notification Service (MPNS) ซึ่งเป็นบริการของ Microsoft ที่ทำงานร่วมกับ Windows Phone อยู่แล้ว ซึ่งสามารถที่จะสร้าง App เพื่อทำการ Push Notification ไปยัง Windows Phone Client ได้อย่างง่ายดาย

บทความนี้จะเป็นตัวอย่างที่ต่อยอดมาจาก Code ของตอนที่ 3


บน Project ของเราที่ไฟล์ App.xaml.cs เพิ่งคำสั่งนี้เข้าไป

using Microsoft.Phone.Notification;


และ method นี้

public static HttpNotificationChannel CurrentChannel { get; private set; }

private void AcquirePushChannel()
{
	CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");

	if (CurrentChannel == null)
	{
	    CurrentChannel = new HttpNotificationChannel("MyPushChannel");
	    CurrentChannel.Open();
	    CurrentChannel.BindToShellTile();
	}

}


Code นี้จะเป็นคำสั่งสำหรับการแจ้งเตือน Notification จาก Mobile Services

ใน method ของ Application_Launching ในไฟล์ App.xaml.cs ให้เพิ่มตัวนี้ลงไป

AcquirePushChannel();


ในไฟล์ MainPage.xaml.cs เพิ่ม Column ชื่อว่า

[JsonProperty(PropertyName = "channel")]
public string Channel { get; set; }


ให้สร้าง Button และสร้าง Event นี้

private void ButtonSave_Click(object sender, RoutedEventArgs e)
{
    var todoItem = new TodoItem { Text = TodoInput.Text, 
        Channel = App.CurrentChannel.ChannelUri.ToString() };
    InsertTodoItem(todoItem);
}


ในภายใต้ Solution Explorer -> Properties, เปิดไฟล์ WMAppManifest.xml คลิกที่ Capabilities และเลือก ID_CAP_PUSH_NOTIFICATION

Push Notifications Azure Mobile Services Windows Phone

กลับมายังหน้า Mobile Services Portal Management บน Windows Azure

Push Notifications Azure Mobile Services Windows Phone

คลิกที่ DATA เลือก Table ของเราที่ได้สร้างไว้

Push Notifications Azure Mobile Services Windows Phone








ในส่วนของ Insert ให้เพิ่ม คสั่งนี้เข้าไป

function insert(item, user, request) {
    request.execute({
        success: function () {
            // Write to the response and then send the notification in the background
            request.respond();
            push.mpns.sendFlipTile(item.channel, {
                title: item.text
            }, {
                success: function (pushResponse) {
                    console.log("Sent push:", pushResponse);
                }
            });
        }
    });
}


คำสั่งสำหรับ Push Notification บน Mobile Serveries

ทดสอบการทำงาน

Push Notifications Azure Mobile Services Windows Phone

ทำการรันโปรแกรม จากนั้นในหน้าแรกบน Windows Phone ให้ทำการ Pin to Start ใน App ของเรา

Push Notifications Azure Mobile Services Windows Phone

ตอนนี้ App มาอยู่ในหน้า launch ในหน้าแรกเรียบร้อยแล้ว

Push Notifications Azure Mobile Services Windows Phone

เปิด App ลองทดสอบทำการส่ง Push

Push Notifications Azure Mobile Services Windows Phone

Push ก็จะทำการส่งไปยังหน้า Pin ใน App ของเรา








บทความถัดไปที่แนะนำให้อ่าน


บทความที่เกี่ยวข้อง


   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2013-05-11 21:16:17 / 2017-03-24 11:33:25
  Download : No files
 Sponsored Links / Related

 
ตอนที่ 1 : Windows Phone(WP) กับ Mobile Services บน Windows Azure คืออะไร
Rating :

 
ตอนที่ 2 : เตรียม Windows Phone(WP) ก่อนที่จะเขียนบน Azure Mobile Services
Rating :

 
ตอนที่ 3 : การสร้าง Windows Phone(WP) กับ Mobile Services และการเรียกใช้งาน
Rating :

 
ตอนที่ 4 : สร้าง Project Windows Phone(WP) และการเชื่อมต่อกับ Mobile Services
Rating :

 
ตอนที่ 5 : Widows Phone สร้าง Table บน Mobile Services และการ Insert ข้อมูล
Rating :

 
ตอนที่ 6 : Windows Phone (WP) อ่าน Data จาก Table ของ Azure Mobile Service
Rating :

 
ตอนที่ 7 : อ่านข้อมูล Mobile Services การใช้ Where แสดงผลบน Windows Phone
Rating :

 
ตอนที่ 8 : การทำ Authentication in Azure Mobile Services ด้วย Windows Phone
Rating :

 
ตอนที่ 10 : Validate และ Modify data in Mobile Services บน Windows Phone
Rating :

 
ตอนที่ 11 : สร้าง Refine Mobile Services queries with paging บน Windows Phone
Rating :

 
ตอนที่ 12 : Scripts to authorize users in Mobile Services บน Windows Phone
Rating :

 
ตอนที่ 13 : Show Case 1 : Register Form (WP and Mobile Services)
Rating :

 
ตอนที่ 14 : Show Case 2 : Login User Password (WP and Mobile Services)
Rating :

 
ตอนที่ 15 : Show Case 3 : Update Data (WP and Mobile Services)
Rating :

 
ตอนที่ 16 : Show Case 4 : Delete Data (WP and Mobile Services)
Rating :

 
ตอนที่ 17 : บทความอื่น ๆ เกี่ยวกับ Windows Phone กับ Azure Mobile Services
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่