字幕组成品列表(Beta)
  • 写在前面
  • Android 平台
    • Game On! 游戏开发系列 - 031
      • Pie Noon - 1503060393
      • The Death of Base Game Activity - 1504030543
      • Surviving OpenGL Context Loss - 1504030546
      • WebP for Game Devs - 1504030547
      • Saved Games In-Depth (Part 1) - 1504070556
      • Saved Games In-Depth (Part 2) - 1504030548
      • Smaller Flipbook Textures with CRABBY - 1504030544
      • Google Tag Manager - 1504030545
      • Flatbuffers - 1505050794
      • Achievement Point Pointers - 1505050796
      • Frequency Scaling - 1505050797
      • Meet the Management APIs - 1501140367
      • Y U Ship Broken Games - 1505050795
    • Android 性能优化 - 088
      • Garbage Collection in Android - 1503170425
      • Performance Cost of Memory Leaks - 1503170424
      • Rendering Performance 101 - 1501130351
      • Understanding Overdraw - 1501130352
      • Understanding VSYNC - 1501130353
      • Tool - Profile GPU Rendering - 1501130354
      • Why 60fps? - 1501130355
      • Android UI and the GPU - 1501130356
      • Invalidations, Layouts, and Performance - 1501130357
      • Overdraw, Cliprect, QuickReject - 1501130358
      • Tool - Memory Monitor - 1501130363
      • Battery Performance 101 - 1501130364
      • Understanding Battery Drain on Android - 1501130365
      • Battery Drain and WakeLocks - 1501130366
      • Memory Performance 101 - 1504170661
    • I/O 2014 Android 开发专题 - 089
      • Activity Transitions - 1504020505
      • Building Apps For Android TV - 1504020520
      • Building great Android media experiences - 1504020510
      • Building a quality app from start to finish - 1504020515
      • App Indexing API - 1504020507
      • What's new in WebView - 1504010484
      • Bluetooth Low Energy - 1504010486
      • Building impressive Android media experiences - 1504010493
      • The next Generation of Authentication - 1504020497
      • Don't Alpha That Pixel! - 1504020523
      • NFC + HCE Your phone in an interactive world - 1504020509
      • Demystifying encodes and decodes of WebM - 1504020521
      • Google Cloud Messaging - 1504020524
      • Getting your Game on the Big Screen - 1504020518
      • I hear you like realtime memes - 1504020511
      • Offerize your App - 1504020506
      • Using the Android Job Scheduler - 1504020504
      • From Holo to Material - 1504020526
      • Under the Hood of Android Auto - 1504020501
      • Isolation for Android App Developers - 1504020498
      • Android Work - 1504010496
      • ExoPlayer: Adaptive video streaming on Android - 1504010489
      • Sample rates and resampling: Why can't we all just agree? - 1504010488
      • Drive Android API - 1504010485
    • Android Studio - 004
      • Layout Editor (Ep 3, Android Studio) - 1503290479
      • Introducing Gradle (Ep 2, Android Studio) - 1503170426
    • I/O 2014 Android 分发主题 - 091
      • Introduction to Google Play - 1504030534
      • Google Play: building your user community - 1504030535
      • Optimizing Apps for Education - 1504030536
      • Succeeding in Education Technology - 1504030530
      • Subscriptions Made Easy with Google Play - 1504030531
      • The world is your playground - go global with Google - 1504030533
      • Maximizing discoverability on Google Play - 1504030538
    • Android Auto - 003
      • Introduction to Android Auto - 1504130615
      • Android Auto Messaging - 1504130617
      • Android Auto Audio - 1504130616
    • Android Wear - 006
      • Designing for Android Wear - 1503210448
      • How We Customized Google Apps for Android Wear - 1503210450
      • Fullscreen apps for Android Wear - 1503210445
      • New Notification Features for Android Wear - 1503210446
      • Building Cloud-powered wearable Apps - 1503210449
      • An Introduction to Android Wear - 1503190435
      • Google I/O 2014 - Android Wear: The developer's perspective - 1503210442
      • Devoxx 2014 Interviews: Android Wear - 1503210440
      • DevBytes: Watch Faces for Android Wear - 1503210439
    • Android TV - 005
      • Using the Leanback library - 1504080588
      • Beach Buggy Racing Multiplayer with Nearby Connections (Play Services) - 1503060387
    • Android for Work - 106
      • Android for Work for Developers - 1503060390
      • App Configurations, Testing and Launchers - 1504110590
    • IO Bytes 2014 - Android - 066
      • Chrome Apps on Android and iOS - 1501080014
      • Perf Primer CPU, GPU and your Android game - 1501080017
  • Chrome 平台
    • IO Bytes 2014 - Chrome and Web - 067
      • Using the PageSpeed API - 1505070815
      • Fabulous Forms for the multi-device web - 1505070816
      • Testing multi-screen web pages - 1505070817
      • Responsive images today - 1505070819
      • Web Performance Testing at YouTube - 1505070828
      • Building sites for the multi-device web - 1505070820
      • Deep dive: Google Cloud Messaging for Chrome - 1505070827
  • Google 创业者资源
    • Coffee with a Googler - 012
      • Chat with Allen Huang of AndroidTV - 1503040384
      • Chat with Fred Chung about developer advocacy - 1503070395
      • Google Fit platform with Michelle Haq - 1503210443
      • Android Auto Product Manager Andrew Brenner - 1501120027
      • Chat with Francis Ma about Google Play services - 1501120028
    • Root Access For Startups - 077
      • What we learned building plug-ins for Android, with startup Magnet - 1503230453
      • How to use crowdfunding to your advantage, with startup Hale Devices - 1503280462
      • How to overcome customer objections when selling tech, with startup Guesswork - 1503280458
    • First Things First - 029
      • Getting started with Android: A crash-course in developing for Android - 1504120601
      • How to ask a question: conducting research for your startup - 1504120603
      • MVP Design Hacks: transform your hot idea into a validated prototype - 1504120602
      • Build something people want: Solving real problems - 1504120605
    • How I - 061
      • Use BigQuery to find my most valuable customers - 1504070573
      • Manage beta testing communities using Google Play - 1504070572
      • Use paper wireframing to build native prototypes - 1504070570
      • Used social media and $0 marketing to get 68 million users - 1504070568
      • Prep to fundraise with four questions - 1504070564
      • Validated my idea in 2 days (with no code) - 1504070562
      • Build open platforms on Android - 1504120596
      • Get cheap, automatic analytics for my business using BigQuery - 1504070571
      • Write press releases to get international media coverage - 1504070569
      • Test beta-product features using Google Apps - 1504070563
      • Use URL builder to measure ROI on social media - 1504070561
      • Use events to build DeadSocial's brand - 1504070557
      • Use BigQuery to visualize streaming data - 1503220452
      • Find, screen, and hire developers - 1503120406
      • Drive engagement with social challenges - 1504070558
  • 设计
    • DesignBytes - 017
      • Paper and Ink: The Materials that Matter - 1505050793
  • 云计算
    • DevBytes: Google Cloud Platform - 021
      • Powering the next killer app with the Google Cloud Platform - 1504210672
      • Introduction to Google Cloud Endpoints - 1504210675
      • The Beauty of Scale with Google Cloud Platform - 1504210678
    • Google Cloud Platform - Big Data - 105
      • GDELT & BigQuery: Understand the world - 1502200379
    • Uncategorized - 999
      • Introducing Google Cloud Platform Resources - 1501190370
  • Google 应用开发
    • Launchpad Online - 072
      • The Setup: Creating new apps using Google APIs - 1503190428
      • Listing your files in Google Drive - 1503190429
      • Customizing Google Analytics for your startup - 1503290473
      • The Launchpad Online series - 1503190427
      • Getting started with Google Analytics - 1503290472
      • Accessing Google Maps from a spreadsheet?!? - 1502220381
      • Change the world in 10 lines of code - 1503080398
    • Google Play Services - 054
      • Google Play services 6.1 - 1503290481
      • Google Play Services 7.0 - 1503200437
      • Google Play Services 6.5 - 1501080015
    • 谷歌地图 iOS SDK - 053
      • Maps Live: New Features in the Google Maps Mobile APIs for Android and iOS - 1504300777
    • Google 移动搜索开发 - 055
      • Is your app in the Google index? - 1504120598
      • Get more engaged users with Google Search for Developers - 1503070397
    • DevBytes: Google Cast - 020
      • Google Cast SDK for Android - 1504180666
      • Media Router Framework - Part 1 - Media Router API - 1504180667
      • Overview for Google Cast Receivers - 1504180664
      • Google Cast SDK for iOS - 1504180663
    • Getting Started with the Google Maps SDK for iOS - 035
      • Getting started with the Google Maps SDK for iOS, Part 1 - 1504270757
    • IO Bytes 2014 - Wearables - 070
      • Voice Driven GDK Glassware - 1505280836
    • Route 85 - 078
      • Introducing Route 85 - 1501120022
      • Quick Tip: Don't Default that Switch! - 1501190371
      • OpenInChrome on iOS, Part 1 - 1501120023
      • OpenInChrome on iOS, Part 2 - 1501120024
      • OpenInChrome on iOS, Part 3 - 1501120025
      • OpenInChrome on iOS, Part 4 - 1501120026
    • DevBytes 2014 - 019
      • Web Components - Template - 1505040789
      • Wearable DataLayer API - 1505050792
      • Using srcset for responsive images - 1505050790
      • The picture element for art direction - 1505050791
    • Uncategorized - 999
      • Sun Surveyor brings augmented reality to photographers using Google Maps APIs - 1504200668
      • Snappy travels with the Roads API - 1503060392
      • Easy Maps Apps in Java and Python - 1501140030
  • Google 广告平台
  • Polymer
    • Polycasts - 076
      • The Awesome Power of Auto-Binding Templates -- Polycasts #08 - 1502220382
      • Content Switcheroo with Core-Pages -- Polycasts #09 - 1502200380
      • Core Iconset -- Polycasts #02 - 1505040788
  • Web 平台
    • HTTP 203 - 062
      • Gotchas - 1501140368
      • Font Rendering - 1501080016
    • Web Components - 081
      • DevBytes: Web Components - Overview - 1504250709
  • 宣传视频
    • Uncategorized - 999
      • Google Developers - 1501150369
      • I/O Extended 2014 - Join me - 1502220383
  • Google 各类开发者会议
    • 2014 Chrome 开发者高峰会议 - 009
      • Keynote - Chrome Dev Summit 2014 (Darin Fisher) - 1503120407
      • TLS All the Things! - Security with Performance(Chris Palmer) - 1503140412
      • Let’s build some apps with Polymer!(Rob Dodson) - 1503150415
      • Day One Closing Remarks(Sundar Pichai) - 1503150417
      • Chrome Leadership panel - 1503160422
      • Fundamentals of Mobile Web Development(Matt Gaunt) - 1503150416
    • 2015 游戏开发者大会中 - 039
      • FlatBuffers - 1504150640
      • Games for Google Cast - 1504150637
      • Top 10 Things Android Game Developers Should Know v 3.0 - 1504150643
      • Automate Publishing for Google Play APIs - 1504150639
      • 3 Game Design Mistakes You're Making - 1504150636
      • Android TV - 1504150638
      • How to Go Viral Without Really Trying - 1504150641
    • Devoxx 2014 Interviews - 024
      • What's new in Android 5.0 Lollipop - 1504260740
      • Android Tools - 1504260743
      • BigQuery and user-defined functions - 1504260744
    • IO Bytes 2014 - 065
      • Dart in Google Cloud - 1505070810
      • Big genomic data on Google Cloud Platform - 1505070811
      • Easy International Checkout with Chrome - 1505070802
      • Google developer tools and APIs for iOS - 1503190436
      • Whet your appetite with IO Bytes - 1501080021
    • PlayTime@Shanghai - 095
      • 主题演讲 Chris Yerga - 1504060549
      • 如何成功地开发你的应用 Ellie Powers - 1504060550
      • 在Google上营利 Brahim Elbouchikhi - 1504060551
      • Playtime Shanghai event sizzle reel - 1504070552
    • Project Google I/O 2015 - 098
      • Project Tango Mobile 3D tracking and perception - 1506120857
      • Democratizing Education - 1506120868
      • Improve your Android app’s accessibility - 1506120864
      • Google Cloud Messaging 3.0 - 1506120844
      • Developers connecting the world through Google Play - 1506120862
  • 开源开放技术
    • Compressor Head - 013
      • The Trailer, Season 2 - 1503060385
      • Behind the Scenes - 1503210441
      • Arithmetic Compression (Ep 5, Compressor Head) Google - 1503070394
      • Introducing Compressor Head - 1502120372
      • Episode 1 (Variable Length Codes) - 1502120373
      • Episode 2 (The LZ77 Compression Family) - 1502120374
      • Episode 3 (Markov Chain Compression) - 1502120375
Powered by GitBook
On this page
  • 译者信息
  • 解说词中文版:

Was this helpful?

  1. Android 平台
  2. I/O 2014 Android 开发专题 - 089

Google Cloud Messaging - 1504020524

PreviousDemystifying encodes and decodes of WebM - 1504020521NextGetting your Game on the Big Screen - 1504020518

Last updated 5 years ago

Was this helpful?

视频发布时间

2014年6月25日

视频介绍

Learn how to use GCM User Notifications feature to enable your app to deliver notifications to multiple devices belonging to the same user and how to handle synced dismissals.

视频推介语

暂无,待补充。

译者信息

翻译

润稿

终审

原始链接

中文字幕

翻译流水号

加入字幕组

田源

黄莘

--

1504020524

解说词中文版:

大家好

我叫Subir 在Google主要负责云消息团队

今天 我们来聊聊Google Cloud Messaging(GCM)中的和与GCM相关

的一些酷炫的API

GCM提供了从服务器向设备高效便捷发送信息

的一系列底层API

我想感谢一下所有使用Google Cloud Messaging的开发者们

因为它确实通过降低电池寿命、无线电启动

和网络信号搜索对程序的影响

提升了生态系统的用户体验

我们先来看看一些使用GCM之前所需的API

要使用GCM,程序需要一个注册ID(Registration ID)

使用Registration ID向特定设备发送消息。

多播允许用户通过一个单一请求向最多1000个目标

发送消息

而且你可以为每个请求设置Time To Live

通知GCM处理过期消息

那么在2014年有什么新特性呢?

今天 我会介绍三个GCM提供的

主要特性--基于XMPP的云连接服务

上行消息,和用户通知

在2013年,我们将这些API开放给了小部分开发者

之后,我们向这些API添加了一些新特性

是他们运行更快速,更健壮

我们收到了大量的来自开发者对于这些API

的兴趣和反馈

这里我很高兴的通知大家

现在这些服务已经向所有开发者开放

下面我们聊聊GCM中关于XMPP的内容,

它也被称为云连接服务(Cloud Connection Server)

云连接服务 或者说CCS

为GCM服务提供了

持续的 异步的 双向的连接

这是一个很强大的服务

它为你的服务器和你用户的UCM所连接的设备

提供了一个虚拟连接

这个连接可以用来发送和接收消息

这是如何连接CCS的方法

我用到了Python里的XMPP库来连接CCS

正如你看到的,地址是gcm.goobleapis.com而端口是5235

你只需连接到这个终端

并用你的API key进行认证就行。

下一步就是发送消息

这些信息中包含JSON数据

其中封装了目的地,应用数据,和一个消息ID

由于通过XMPP发送消息是异步的

消息ID就是用来唯一标识XMPP连接的

所以当CCS向你的服务器回发ACK的时候

它会使用消息ID来识别消息

所以这个消息ID不仅要是唯一的

而且要出现在请求中

我们来看看ACK或者NACK消息

是什么样的

消息类型会说明它是ACK还是NACK

而对于NACK来说 还会有错误代码

来描述遇到的问题

所以当要实现一个CCS连接的时候 这就是你需要知道的。

我们允许每个发送者使用最多发送100个连接

而每个连接最多能发出的消息数也是100

改进的错误处理机制能让你

更快定位出错的位置

这是一个控制消息的例子

它描述了一个即将关闭的连接

这条消息的意思是发送者不应该再向

这个连接发送消息

所有再发送到该连接的消息

都会收到一个NACK 其中带有错误代码

告知发送者这个链接即将关闭

我们还添加了其它类型的错误代码

比如和JSON解析相关的,等等

那么目前为止我们学习了当XMPP作为末端

GCM可以提供与你的服务器之前的

持续的,双向的连接

我们也看到了如何通过这个连接

向设备发送消息

下面 我们来看看极好的上行消息

API 它会帮你从应用程序里

向服务器发消息

我们已经做了很多工作

来使上行消息更快 更稳定

而且我很高兴的告诉大家现在该功能也向所有开发者开放了

那么我们来看一下

由于设备和GCM之间的连接已经存在了

它是低延迟发送 所以就不需要握手

如果设备离线了这些消息会在本地进行存储

并在有连接以后发送出去

我们使用在下行消息中

同样的可靠消息队列技术

所以如果和服务器断开了连接

我们会在重新建立连接之后发送一次消息

一旦收到来自你服务器的ACK 我们会删掉这些消息

要接收上行消息

你的服务器首先需要连接到CCS

这是例子展示了如何使用Google云消息API

发送消息。

将Project ID设置为目的地

之后我们会将消息发送到你的服务器

你可以发送并且在调用API的时候设置Time To Live

这就是ACK

重申一下 由于返回是异步的

MessageID是用来标识消息的

这儿有些在使用上行消息的时候的注意事项

待发消息不能超过100

如果你的服务器断开连接超过24小时

我们会删除你的消息

我们同样允许单一设备发送最大20条

未被接收确认的上行消息

所以接收确认是必须的

同时与下行消息类似

上行消息的最大负载容量是4k

这是一些GCM中我喜欢的API----发送状态反馈(Delivery Receipts)

当向设备发送消息时 开发者们的普遍需求是

能够获得消息的内部状态

来获知消息是否被成功发送

比如 你正在开发一个消息应用

而且当消息成功发送后会通知发送者

现在通过CCS 你可以实现该功能了。

我们正在添加这个新特性 叫做发送回复(Delivery Receipts)

这个例子告诉你如何向消息请求回复

在消息的JSON负载中,

你仅仅需要将Delivery Receipt Requested设置为True即可

这个值默认是设置为False的

这是一个回复消息

这个消息会有一个新的消息ID

来源会设置为gcm.google.apis.com 而类型会设置为"回复"

在返回数据中有四个域要添加

消息状态,原始消息ID,发送时间

最初消息的注册ID

目前,用户已经普遍拥有多种设备

所以会多次收到通知

这个功能会较少通知,使通知变得更加实用而不是惹人讨厌

幸亏GCM提供了一种简便的方式来通知多个设备

叫做用户通知,通过该功能

你可以同步用户通知,包括已经解除的通知

未来我会深入讲讲接触通知相关的东西

通过用户通知 你可以通过单一请求

向用户的所有终端发起通知

这是一个非常强大的API

它能简化你的通知

我会给你几个例子

你可以设置一个短的TTL,那么通知仅仅

发送给当前连接的设备

另一个例子是使用空闲延迟(Delay While Idle)选项

想象一下你的用户整天带着手机

而平板电脑留在家里

通过设置Delay While IDLE和TTL

你可以仅向正在使用的手机发通知

很实用,不是吗?

要向用户的所有设备发送消息

你需要一个Notification Key(通知键值)

应用服务器可以通过添加或者删除

Notification Key名称来获得键值

我们来看看如何获得Notification Key

这是一个获得键值和HTTP头部的末端

这个请求是使用你的项目API Key进行认证的

所以首先 我们要向Notification Key添加注册

你可以做一次Create

如果用户在其它设备上安装了该应用

你可以用一个Add

而最重要的域是Notification Key Name

对我们来说,它是一个唯一的标识

你可以通过该标识辨认用户

真正的用户名称是无关的

所以请使用哈希

对于用户来说必须是唯一的

这是一个例子,它展示了你如何

向用户的所有设备发送消息

唯一的不同是我们现在向注册ID发送一个Notification Key

而不是发送消息

现在让我们来假设一下用户在一个设备上操作通知

而我们希望能在所有设备上

解除通知

那么我们如何实现它呢?

通过上行消息,我们可以向Notification Key发送消息

而GCM会向其它与这个key相关的

注册设备发送消息

这样,你可以通知其它设备

解除通知,因为该通知在一台设备中已经被处理过了

此外,你也可以在单独上行消息中

发送"Get to a Project ID"消息到

你的应用服务器

这是一个例子

正如你看到的 上行消息中的这两个域

要设置为Notification Key

GCM会将该消息发送到

和这个Key相关的其他设备上

User Notification在HTTP和XMPP上都可以用

它可以支持每个Notification Key中最多20个设备

当然 请求中的key name对于用户来说必须是唯一的

在我们结束前 我建议大家看看

所有GCM API和服务的相关文档

和通常一样 就是这个链接

感谢观看

希望大家喜欢使用新的API和服务

并且从视频中有所收获

Youtube
Youtube
加入 GDG 字幕组
video_screenshot