1. Windows Azure! Push & DB 2014 4 24
2. ! http://xenonix.com! [email protected]
3. Notication services ! = Push
4. . ! Mobile service Push Notication hub
5. Mobile service Push
6. Notication Hub
http://msdn.microsoft.com/en-us/library/jj927170.aspx
7.
http://www.slideshare.net/youngjaekim58/20140403-tech-daysazurenoticationhubservicebus
8.
http://www.slideshare.net/youngjaekim58/20140403-tech-daysazurenoticationhubservicebus
9.
http://www.slideshare.net/youngjaekim58/20140403-tech-daysazurenoticationhubservicebus
Mobile service push ! ! Push ! Notication Hub! Push
10. MS . .
http://azure.microsoft.com/en-us/documentation/articles/
mobile-services-android-get-started-push/ Push notication using
Azure Mobile service
11. . Get started Notication Hubs
http://azure.microsoft.com/en-us/documentation/articles/
notication-hubs-android-get-started/
12. Azure . ! .
13. account.windowsazure.com
14. https://console.developers.google.com
15. azuresdk-android-1.1.5.zip
16. .
17. google-play-service
18. google-play-service
19. AndroidManifest.xml
20. MainActivity.java public class MainActivity extends
Activity { ! private String SENDER_ID = SENDER_ID"; private
GoogleCloudMessaging gcm; private NoticationHub hub;
21. MainActivity.java @SuppressWarnings("unchecked") private
void registerWithNoticationHubs() { new AsyncTask() { @Override
protected Object doInBackground(Object... params) { try { String
regid = gcm.register(SENDER_ID); hub.register(regid); } catch
(Exception e) { return e; } return null; } }.execute(null, null,
null); }
22. MainActivity.java @Override protected void onCreate(Bundle
savedInstanceState) { ( )
NoticationsManager.handleNotications(this, SENDER_ID,
MyHandler.class); ! gcm = GoogleCloudMessaging.getInstance(this); !
String connectionString = CONNECTION_STRING"; hub = new
NoticationHub(NOTIFICATION_HUB_NAME, connectionString, this); !
registerWithNoticationHubs();
23. CONNECTION STRING Service Bus
24. SENDER_ID
25. import android.os.AsyncTask; import
com.google.android.gms.gcm.*; import
com.microsoft.windowsazure.messaging.*; import
com.microsoft.windowsazure.notications.NoticationsManager;
MainActivity.java SDK libs F5 !
26. MyHandler.class !!! ! !
27. MyHandler Receiver .
28. AndroidManifest.xml lter>
29. MyHandler.java ! public static nal int NOTIFICATION_ID = 1;
private NoticationManager mNoticationManager;
NoticationCompat.Builder builder; Context ctx; ! @Override public
void onReceive(Context context, Bundle bundle) { ctx = context;
String nhMessage = bundle.getString("msg");
System.out.println("RECEIVE"); ! sendNotication(nhMessage);
Toast.makeText(context, nhMessage, 3).show(); } class
MyHandler
30. MyHandler.java ! private void sendNotication(String msg) {
mNoticationManager = (NoticationManager)
ctx.getSystemService(Context.NOTIFICATION_SERVICE); ! PendingIntent
contentIntent = PendingIntent.getActivity(ctx, 0, new Intent(ctx,
MainActivity.class), 0); ! NoticationCompat.Builder mBuilder = new
NoticationCompat.Builder(ctx) .setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notication Hub Demo") .setStyle(new
NoticationCompat.BigTextStyle() .bigText(msg))
.setContentText(msg); ! mBuilder.setContentIntent(contentIntent);
mNoticationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
class MyHandler
31. Push .
32. script function azurex_push() { var azure =
require('azure'); var noticationHubService =
azure.createNoticationHubService(NOTIFICATION_HUB_NAME,
CONNECTION_STRING');
noticationHubService.gcm.send(null,'{"data":{"msg" : "Hello from
Mobile Services!"}}', function (error) { if (!error) {
console.warn("Notication successful"); } else {
console.warn("Notication failed" + error); } } ); }
33. DB .
34. AndroidManifest.xml MainActivity.java import
com.microsoft.windowsazure.mobileservices.*; private
MobileServiceClient mClient; onCreate( )
35. MainActivity.java import
com.microsoft.windowsazure.mobileservices.*; private
MobileServiceClient mClient; onCreate( ) mClient = new
MobileServiceClient( "https://azurex.azure-mobile.net/",
RnBqhfpTezpdVDRhYM, this );
36. Item . package com.xenonix.azurex; ! public class Item { !
public String Id; public String Text; }
37. DB . Item item = new Item(); item.Text = "Awesome item";
mClient.getTable(Item.class).insert(item, new
TableOperationCallback() { public void onCompleted(Item entity,
Exception exception, ServiceFilterResponse response) { if
(exception == null) { // Insert succeeded } else { // Insert failed
} } });
38. http://xenonix.com .
LOAD MORE