SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Google Cloud Messaging for
Android


Shcheglov Maksym
MTS1 at Magento inc.
Google Cloud Messaging for Android
     GCM & C2DM
• no signup to get access;
• no authentication using Google account;
• no message quota.
Google Cloud Messaging for Android
     Requirements
• Android 2.2 or higher;
• Google account (OS version < Android 4.0.4);
• project ID (using Google API console);
• API key (using Google API console).
Google Cloud Messaging for Android
Requirements
Google Cloud Messaging for Android
Requirements
Google Cloud Messaging for Android
Enabling GCM



          GCM                              Server
                           Sender ID,
                          Application ID
             2

                  1
Registration ID                                     Registration ID

                                       3

                      Mobile phone
Google Cloud Messaging for Android
            Enabling GCM
import com.google.android.gcm.GCMRegistrar;



public class UAMobileActivity extends Activity {



    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        final String regID = GCMRegistrar.getRegistrationId(this);

        if (regID.equals("")) {

            // register application

            GCMRegistrar.register(this, "484449755275");

        } else {

            // Device is already registered on GCM

        }

    }

}
Google Cloud Messaging for Android
        Enabling GCM
import com.google.android.gcm.GCMBaseIntentService;



public class GCMIntentService extends GCMBaseIntentService {



    @Override

    protected void onRegistered(Context context, String registrationID) {

        //send registrationID to the server

        registerOnServer(context, registrationID);

    }



}
Google Cloud Messaging for Android
Sending a message

                                      1



    GCM          A message with API
                                          Server
                        key,
                   Registration ID
      2




                    Mobile phone
Google Cloud Messaging for Android
             Sending a message
             Request

https://android.googleapis.com/gcm/send



HTTP headers:



Content-Type:application/json

Authorization:key=AIzaSyAIpOT5VHEOthyrwKjwrNwwEVHQIgioypk



HTTP body:



{

    “collapse_key” : “news_update”,

    “time_to_live” : 100,

    “delay_while_idle” : true,

    "data" : { ... },

    "registration_ids" : [”ID1”, “ID2”, “ID3”],

}
Google Cloud Messaging for Android
        Sending a message
        Response

{

    "multicast_id": 112,

    "success": 2,

    "failure": 1,

    "canonical_ids": 1,

    ”results": [

        { “message_id": "1:2036" },

        { "message_id": "1:7695", "registration_id": ”102" },

        { "error": "NotRegistered"}

    ]

}
Google Cloud Messaging for Android
        Sending a message
        Client
import com.google.android.gcm.GCMBaseIntentService;



public class GCMIntentService extends GCMBaseIntentService {



    @Override

    protected void onMessage(Context context, Intent intent) {

        // received the message

        final Bundle bundle = intent.getExtras();

        String data = bundle.getString("some_data");

    }



}
Google Cloud Messaging for Android
      Unregistration
• manually by sending an intent
  com.google.android.c2dm.intent.UNREGI
  STER;
• uninstall the application;
• registration ID is expired;
• application is updated, but does not have a broadcast
  receiver configured to receive
  com.google.android.c2dm.intent.RECEIV
  E intents.
Google Cloud Messaging for Android
Unregistration
                             Device not
                           registered error
            5
                                              1

                                              4
    GCM                                           Server

                           invalidate
      2
                 3




                     Mobile phone
Google Cloud Messaging for Android
      Message states
• sent;
• stored (a device is offline);
• collapsed (a device is offline & we have a new message);
• throttled.
Google Cloud Messaging for Android
     Concepts
• send-to-sync;
• message with payload.
Google Cloud Messaging for Android
     Features
• no broadcasting;
• no guarantees about delivery and order;
• message multicasting (up to 1000 devices per 1 request);
• multiple senders (max 100 project IDs per application);
• store up to 100 non-collapsible messages;
• maximum 4kb per message;
• optimizations;
• analytics.
Google Cloud Messaging for Android
         How to migrate from C2DM
Client
• deliver a new version of your app;
• send a flag with registration ID.


Server
• new endpoint;
• API key in the Authorization header.
Google Cloud Messaging for Android
      GCM & APNS
• no certificates;
• one http address for development and production;
• uses json or plaint text in requests, not binary data;
• no feedback service;
• developer-friendly error codes;
• no actions (alert/badge/sound);
• message size (4kb & 256b).
Demo
Q&A

Mais conteúdo relacionado

Mais procurados

Gcm presentation
Gcm presentationGcm presentation
Gcm presentationNiraj Singh
 
Push it! How to use Google Cloud Messaging in your Android App
Push it! How to use Google Cloud Messaging in your Android AppPush it! How to use Google Cloud Messaging in your Android App
Push it! How to use Google Cloud Messaging in your Android AppAchim Fischer
 
GCM with Pushbots
GCM with PushbotsGCM with Pushbots
GCM with PushbotsAshish RAj
 
GOOGLE CLOUD MESSAGING PPT 2017
GOOGLE CLOUD MESSAGING PPT 2017GOOGLE CLOUD MESSAGING PPT 2017
GOOGLE CLOUD MESSAGING PPT 2017ketan Bordekar
 
Firebase Cloud Messaging Device to Device
Firebase Cloud Messaging Device to DeviceFirebase Cloud Messaging Device to Device
Firebase Cloud Messaging Device to DeviceTakuma Lee
 
GCM Technology for Android
GCM Technology for AndroidGCM Technology for Android
GCM Technology for AndroidRanjitha R_14
 
google cloud messaging
google cloud messaginggoogle cloud messaging
google cloud messagingBhavana Sharma
 
ID Android TechTalk Series #6 : Google Service and Gradle - Andrew Kurniadi
ID Android TechTalk Series #6 : Google Service and Gradle - Andrew KurniadiID Android TechTalk Series #6 : Google Service and Gradle - Andrew Kurniadi
ID Android TechTalk Series #6 : Google Service and Gradle - Andrew KurniadiDicoding
 
Android BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiverAndroid BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiverSriSankeerth Reddy
 
Android Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App EngineAndroid Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App EngineLars Vogel
 
Firebase on Android: The Big Picture
Firebase on Android: The Big PictureFirebase on Android: The Big Picture
Firebase on Android: The Big PictureSriyank Siddhartha
 

Mais procurados (18)

Gcm presentation
Gcm presentationGcm presentation
Gcm presentation
 
FCM & GCM
FCM & GCMFCM & GCM
FCM & GCM
 
Push it! How to use Google Cloud Messaging in your Android App
Push it! How to use Google Cloud Messaging in your Android AppPush it! How to use Google Cloud Messaging in your Android App
Push it! How to use Google Cloud Messaging in your Android App
 
GCM with Pushbots
GCM with PushbotsGCM with Pushbots
GCM with Pushbots
 
GOOGLE CLOUD MESSAGING PPT 2017
GOOGLE CLOUD MESSAGING PPT 2017GOOGLE CLOUD MESSAGING PPT 2017
GOOGLE CLOUD MESSAGING PPT 2017
 
Gcm tutorial
Gcm tutorialGcm tutorial
Gcm tutorial
 
Firebase Cloud Messaging Device to Device
Firebase Cloud Messaging Device to DeviceFirebase Cloud Messaging Device to Device
Firebase Cloud Messaging Device to Device
 
Magda badita gcm
Magda badita  gcmMagda badita  gcm
Magda badita gcm
 
GCM Technology for Android
GCM Technology for AndroidGCM Technology for Android
GCM Technology for Android
 
google cloud messaging
google cloud messaginggoogle cloud messaging
google cloud messaging
 
GCM aperitivo Android
GCM aperitivo AndroidGCM aperitivo Android
GCM aperitivo Android
 
ID Android TechTalk Series #6 : Google Service and Gradle - Andrew Kurniadi
ID Android TechTalk Series #6 : Google Service and Gradle - Andrew KurniadiID Android TechTalk Series #6 : Google Service and Gradle - Andrew Kurniadi
ID Android TechTalk Series #6 : Google Service and Gradle - Andrew Kurniadi
 
Google cloud messaging
Google cloud messagingGoogle cloud messaging
Google cloud messaging
 
Android BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiverAndroid BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiver
 
Android Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App EngineAndroid Cloud to Device Messaging with the Google App Engine
Android Cloud to Device Messaging with the Google App Engine
 
Firebase
FirebaseFirebase
Firebase
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
Firebase on Android: The Big Picture
Firebase on Android: The Big PictureFirebase on Android: The Big Picture
Firebase on Android: The Big Picture
 

Destaque

AppleWatch発売!Apple Watch WatchKit勉強会-Notification
AppleWatch発売!Apple Watch WatchKit勉強会-NotificationAppleWatch発売!Apple Watch WatchKit勉強会-Notification
AppleWatch発売!Apple Watch WatchKit勉強会-NotificationHiroaki Kaneda
 
COD2013 Windows Azure Mobile Service を用いたiOS/Android開発
COD2013 Windows Azure Mobile Service を用いたiOS/Android開発COD2013 Windows Azure Mobile Service を用いたiOS/Android開発
COD2013 Windows Azure Mobile Service を用いたiOS/Android開発Masaki Yamamoto
 
Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方Daisuke Sugai
 
Web技術勉強会 20130525 - Google Cloud Messaging入門
Web技術勉強会 20130525 - Google Cloud Messaging入門Web技術勉強会 20130525 - Google Cloud Messaging入門
Web技術勉強会 20130525 - Google Cloud Messaging入門龍一 田中
 
PHPでスマホアプリにプッシュ通知する
PHPでスマホアプリにプッシュ通知するPHPでスマホアプリにプッシュ通知する
PHPでスマホアプリにプッシュ通知するTomoki Hasegawa
 

Destaque (7)

AppleWatch発売!Apple Watch WatchKit勉強会-Notification
AppleWatch発売!Apple Watch WatchKit勉強会-NotificationAppleWatch発売!Apple Watch WatchKit勉強会-Notification
AppleWatch発売!Apple Watch WatchKit勉強会-Notification
 
WP201505w2v0
WP201505w2v0WP201505w2v0
WP201505w2v0
 
Apple push notification service
Apple push notification serviceApple push notification service
Apple push notification service
 
COD2013 Windows Azure Mobile Service を用いたiOS/Android開発
COD2013 Windows Azure Mobile Service を用いたiOS/Android開発COD2013 Windows Azure Mobile Service を用いたiOS/Android開発
COD2013 Windows Azure Mobile Service を用いたiOS/Android開発
 
Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方
 
Web技術勉強会 20130525 - Google Cloud Messaging入門
Web技術勉強会 20130525 - Google Cloud Messaging入門Web技術勉強会 20130525 - Google Cloud Messaging入門
Web技術勉強会 20130525 - Google Cloud Messaging入門
 
PHPでスマホアプリにプッシュ通知する
PHPでスマホアプリにプッシュ通知するPHPでスマホアプリにプッシュ通知する
PHPでスマホアプリにプッシュ通知する
 

Semelhante a Максим Щеглов - Google Cloud Messaging for Android

Android chat in the cloud
Android chat in the cloudAndroid chat in the cloud
Android chat in the cloudfirenze-gtug
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmJohan Nilsson
 
勝手に改造 Chrome to Phone
勝手に改造 Chrome to Phone勝手に改造 Chrome to Phone
勝手に改造 Chrome to PhoneRyo Maruyama
 
AC2DM For Security
AC2DM For SecurityAC2DM For Security
AC2DM For SecurityJason Ross
 
Android Cloud To Device Messaging
Android Cloud To Device MessagingAndroid Cloud To Device Messaging
Android Cloud To Device MessagingFernando Cejas
 
Android cloud to device messaging
Android cloud to device messagingAndroid cloud to device messaging
Android cloud to device messagingFe
 
FOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device MessagingFOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device MessagingJohan Nilsson
 
我的GCM時代-推送訊息的實做分享
我的GCM時代-推送訊息的實做分享我的GCM時代-推送訊息的實做分享
我的GCM時代-推送訊息的實做分享Morning Kao
 
GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...
GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...
GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...GoGrid Cloud Hosting
 
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...ijistjournal
 
Xamarin Dev Day
Xamarin Dev DayXamarin Dev Day
Xamarin Dev DayIan Chen
 
GCCP Session #1 - Getting Started with GCP.pptx
GCCP Session #1 - Getting Started with GCP.pptxGCCP Session #1 - Getting Started with GCP.pptx
GCCP Session #1 - Getting Started with GCP.pptxRamshaAshraf12
 
Android C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen ConferenceAndroid C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen ConferenceLars Vogel
 
Automate+ Final Presentation
Automate+ Final PresentationAutomate+ Final Presentation
Automate+ Final PresentationSanat Maharjan
 
Modern Web Cloud Architecture based on Google Technologies
Modern Web Cloud Architecture based on Google TechnologiesModern Web Cloud Architecture based on Google Technologies
Modern Web Cloud Architecture based on Google TechnologiesMichael Ludwig
 
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)Chinnayya Math
 
Android push-applications-android
Android push-applications-androidAndroid push-applications-android
Android push-applications-androidwadise
 

Semelhante a Максим Щеглов - Google Cloud Messaging for Android (20)

Android chat in the cloud
Android chat in the cloudAndroid chat in the cloud
Android chat in the cloud
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG Stockholm
 
Workshop: Android
Workshop: AndroidWorkshop: Android
Workshop: Android
 
A Journey into Google Cloud Messaging
A Journey into Google Cloud MessagingA Journey into Google Cloud Messaging
A Journey into Google Cloud Messaging
 
勝手に改造 Chrome to Phone
勝手に改造 Chrome to Phone勝手に改造 Chrome to Phone
勝手に改造 Chrome to Phone
 
AC2DM For Security
AC2DM For SecurityAC2DM For Security
AC2DM For Security
 
Android Cloud To Device Messaging
Android Cloud To Device MessagingAndroid Cloud To Device Messaging
Android Cloud To Device Messaging
 
Android cloud to device messaging
Android cloud to device messagingAndroid cloud to device messaging
Android cloud to device messaging
 
AutoMate+
AutoMate+AutoMate+
AutoMate+
 
FOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device MessagingFOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device Messaging
 
我的GCM時代-推送訊息的實做分享
我的GCM時代-推送訊息的實做分享我的GCM時代-推送訊息的實做分享
我的GCM時代-推送訊息的實做分享
 
GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...
GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...
GoGrid Webinar: Complex Infrastructure Made Easy - Learn How You Can Leverage...
 
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
GOOGLE CLOUD MESSAGING (GCM): A LIGHT WEIGHT COMMUNICATION MECHANISM BETWEEN ...
 
Xamarin Dev Day
Xamarin Dev DayXamarin Dev Day
Xamarin Dev Day
 
GCCP Session #1 - Getting Started with GCP.pptx
GCCP Session #1 - Getting Started with GCP.pptxGCCP Session #1 - Getting Started with GCP.pptx
GCCP Session #1 - Getting Started with GCP.pptx
 
Android C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen ConferenceAndroid C2DM Presentation at O'Reilly AndroidOpen Conference
Android C2DM Presentation at O'Reilly AndroidOpen Conference
 
Automate+ Final Presentation
Automate+ Final PresentationAutomate+ Final Presentation
Automate+ Final Presentation
 
Modern Web Cloud Architecture based on Google Technologies
Modern Web Cloud Architecture based on Google TechnologiesModern Web Cloud Architecture based on Google Technologies
Modern Web Cloud Architecture based on Google Technologies
 
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
A Google Cloud Solution Minus Dedicated Server - App Only (Server and Client)
 
Android push-applications-android
Android push-applications-androidAndroid push-applications-android
Android push-applications-android
 

Mais de UA Mobile

Владимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-ApplicationsВладимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-ApplicationsUA Mobile
 
Денис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsДенис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsUA Mobile
 
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычкиДмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычкиUA Mobile
 
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in AndroidАлександр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in AndroidUA Mobile
 
Александр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLiteАлександр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLiteUA Mobile
 
Сергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with AndroidСергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with AndroidUA Mobile
 
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опытМихаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опытUA Mobile
 
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideДмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideUA Mobile
 
Павел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузерыПавел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузерыUA Mobile
 
Вадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные граблиВадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные граблиUA Mobile
 
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчикаОлег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчикаUA Mobile
 
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложенийЕвгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложенийUA Mobile
 
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...UA Mobile
 
Tdd objective c
Tdd objective cTdd objective c
Tdd objective cUA Mobile
 
Mobile automation uamobile
Mobile automation uamobileMobile automation uamobile
Mobile automation uamobileUA Mobile
 

Mais de UA Mobile (15)

Владимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-ApplicationsВладимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-Applications
 
Денис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsДенис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPods
 
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычкиДмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
 
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in AndroidАлександр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
 
Александр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLiteАлександр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLite
 
Сергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with AndroidСергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with Android
 
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опытМихаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опыт
 
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideДмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
 
Павел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузерыПавел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузеры
 
Вадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные граблиВадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные грабли
 
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчикаОлег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
 
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложенийЕвгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
 
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
 
Tdd objective c
Tdd objective cTdd objective c
Tdd objective c
 
Mobile automation uamobile
Mobile automation uamobileMobile automation uamobile
Mobile automation uamobile
 

Максим Щеглов - Google Cloud Messaging for Android

  • 1. Google Cloud Messaging for Android Shcheglov Maksym MTS1 at Magento inc.
  • 2. Google Cloud Messaging for Android GCM & C2DM • no signup to get access; • no authentication using Google account; • no message quota.
  • 3. Google Cloud Messaging for Android Requirements • Android 2.2 or higher; • Google account (OS version < Android 4.0.4); • project ID (using Google API console); • API key (using Google API console).
  • 4. Google Cloud Messaging for Android Requirements
  • 5. Google Cloud Messaging for Android Requirements
  • 6. Google Cloud Messaging for Android Enabling GCM GCM Server Sender ID, Application ID 2 1 Registration ID Registration ID 3 Mobile phone
  • 7. Google Cloud Messaging for Android Enabling GCM import com.google.android.gcm.GCMRegistrar; public class UAMobileActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String regID = GCMRegistrar.getRegistrationId(this); if (regID.equals("")) { // register application GCMRegistrar.register(this, "484449755275"); } else { // Device is already registered on GCM } } }
  • 8. Google Cloud Messaging for Android Enabling GCM import com.google.android.gcm.GCMBaseIntentService; public class GCMIntentService extends GCMBaseIntentService { @Override protected void onRegistered(Context context, String registrationID) { //send registrationID to the server registerOnServer(context, registrationID); } }
  • 9. Google Cloud Messaging for Android Sending a message 1 GCM A message with API Server key, Registration ID 2 Mobile phone
  • 10. Google Cloud Messaging for Android Sending a message Request https://android.googleapis.com/gcm/send HTTP headers: Content-Type:application/json Authorization:key=AIzaSyAIpOT5VHEOthyrwKjwrNwwEVHQIgioypk HTTP body: { “collapse_key” : “news_update”, “time_to_live” : 100, “delay_while_idle” : true, "data" : { ... }, "registration_ids" : [”ID1”, “ID2”, “ID3”], }
  • 11. Google Cloud Messaging for Android Sending a message Response { "multicast_id": 112, "success": 2, "failure": 1, "canonical_ids": 1, ”results": [ { “message_id": "1:2036" }, { "message_id": "1:7695", "registration_id": ”102" }, { "error": "NotRegistered"} ] }
  • 12. Google Cloud Messaging for Android Sending a message Client import com.google.android.gcm.GCMBaseIntentService; public class GCMIntentService extends GCMBaseIntentService { @Override protected void onMessage(Context context, Intent intent) { // received the message final Bundle bundle = intent.getExtras(); String data = bundle.getString("some_data"); } }
  • 13. Google Cloud Messaging for Android Unregistration • manually by sending an intent com.google.android.c2dm.intent.UNREGI STER; • uninstall the application; • registration ID is expired; • application is updated, but does not have a broadcast receiver configured to receive com.google.android.c2dm.intent.RECEIV E intents.
  • 14. Google Cloud Messaging for Android Unregistration Device not registered error 5 1 4 GCM Server invalidate 2 3 Mobile phone
  • 15. Google Cloud Messaging for Android Message states • sent; • stored (a device is offline); • collapsed (a device is offline & we have a new message); • throttled.
  • 16. Google Cloud Messaging for Android Concepts • send-to-sync; • message with payload.
  • 17. Google Cloud Messaging for Android Features • no broadcasting; • no guarantees about delivery and order; • message multicasting (up to 1000 devices per 1 request); • multiple senders (max 100 project IDs per application); • store up to 100 non-collapsible messages; • maximum 4kb per message; • optimizations; • analytics.
  • 18. Google Cloud Messaging for Android How to migrate from C2DM Client • deliver a new version of your app; • send a flag with registration ID. Server • new endpoint; • API key in the Authorization header.
  • 19. Google Cloud Messaging for Android GCM & APNS • no certificates; • one http address for development and production; • uses json or plaint text in requests, not binary data; • no feedback service; • developer-friendly error codes; • no actions (alert/badge/sound); • message size (4kb & 256b).
  • 20. Demo
  • 21. Q&A