google-cloud- messaging

#- cloud- messaging 1

1: google-cloud-messaging 2

2

Examples 3

3

Android 5

iOS 6

2: Android iOS 7

Examples 7

7

8 You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: google-cloud-messaging

It is an unofficial and free google-cloud-messaging ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official google-cloud- messaging.

The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.

Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected]

https://riptutorial.com/ko/home 1 1: google-cloud-messaging

Google :

Google (GCM) . .

, " " . GCM 4KB . GCM .

GCM Google , HTTP XMPP .

.

• Google GCM . XMPP . GCM . • App Server HTTP / XMPP GCM . GCM . . XMPP . • GCM . GCM GCM . .

GCM . :

• - GCM . • - GCM ID .

GCM .

• GCM - Google . • - GCM . • App Server - GCM . GCM . XMPP .

• ID API . ID .

• Google . HTTP POST . XMPP SASL PLAIN . . API .

• ID . .

○ Android : .

○ iOS : .

○ Chrome : Chrome .

• GCM ID. .

• GCM . . . • .

○ . . 1. https://riptutorial.com/ko/home 2 GCM . 2. GCM . 3. GCM . 4. . .

○ . GCM . . • . XMPP .

○ . . 1. XMPP . XMPP . 2. XMPP . 3. XMPP .

○ . XMPP . 1. . 2. XMPP "ack" . 3. .

.

Examples

GCM HTTP :

https://gcm-http.googleapis.com/gcm/send Content-Type:application/json Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA { "to": "/topics/foo-bar", "data": { "message": "This is a GCM Topic Message!", } }

( ).

1. POST . 2. . • Content-Type = application / json • = < GCM > 3. Body ( raw . (2) ). 4. https://gcm-http.googleapis.com/gcm/send .

:

(1)

https://riptutorial.com/ko/home 3 (2)

https://riptutorial.com/ko/home 4 message_id .

: . .

Android

GCM catch onMessageReceived . https://riptutorial.com/ko/home 5 @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); // Handle received message here. } iOS application:didReceiveRemoteNotification:fetchCompletionHandler: ( iOS <8.0) application:didReceiveRemoteNotification: GCMService:appDidReceiveMessage:message GCMService:appDidReceiveMessage:message .

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSLog(@"Notification received: %@", userInfo); // This works only if the app started the GCM service [[GCMService sharedInstance] appDidReceiveMessage:userInfo]; // Handle the received message // ... }

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler { NSLog(@"Notification received: %@", userInfo); // This works only if the app started the GCM service [[GCMService sharedInstance] appDidReceiveMessage:userInfo]; // Handle the received message // Invoke the completion handler passing the appropriate UIBackgroundFetchResult value // ... } google-cloud-messaging : https://riptutorial.com/ko/google-cloud-messaging/topic/5811/google- cloud-messaging-

https://riptutorial.com/ko/home 6 2: Android iOS

Examples iOS priority: "high" . .

. "normal" "high". iOS APN 5 10 .

. . .

.

--- FCM

Android iOS : https://riptutorial.com/ko/google-cloud-messaging/topic/6492/android------

https://riptutorial.com/ko/home 7 S. Contributors No

google-cloud- 1 AL., Community messaging

2 Android iOS Niels Abildgaard

https://riptutorial.com/ko/home 8