字幕组成品列表(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. Google 应用开发
  2. Route 85 - 078

OpenInChrome on iOS, Part 3 - 1501120025

PreviousOpenInChrome on iOS, Part 2 - 1501120024NextOpenInChrome on iOS, Part 4 - 1501120026

Last updated 5 years ago

Was this helpful?

视频发布时间

2014年12月18日

视频介绍

Detecting old versions of Chrome. In part 3 of this series, we show you how to detect if the version of Chrome installed on the user's iOS device can support the x-callback-url format. And then we use the OpenInChrome open source class to make your life easier.

视频推介语

暂无,待补充。

译者信息

翻译

润稿

终审

原始链接

中文字幕

翻译流水号

加入字幕组

鲁登科

周亿

--

1501120025

解说词中文版:

欢迎回到我们的Route 85

这是iOS开发者的求知旅行

在那里我们为着伟大的方向而永不停息

今天是我们系列的第三部分

将继续探索在iOS设备上用Chrome打开链接

现在我们回到上次该继续的地方

也许你没有看上次的视频

我们可以在应用程序中直接用Chrome打开一个链接

并且在Chrome中添加一个按钮

利用x-callback URL返回

到我们的应用程序上

但是这里有一个小问题

事实上如果你的Chrome版本非常老的话

比如说超过两年没有更新过

当你尝试打开这个URL时 它就不起作用了

Chrome以前不支持添加x-callback URL

在2012年十一月之后才有此功能

但是由于这个URL仍然是始于Google Chrome方案的

我们的[UIApplication canOpenURL]

方法会返回true或者yes

只有你的Chrome浏览器是老版本的

接收到这个URL才不会处理

那么我们有没有办法看看我们的Chrome的版本是否够新

能不能处理这个x-callback URL呢

有吗

铛 铛 铛

我们可以看看Chrome的开发团队是怎么做的

我感觉他们的办法非常好

它们添加了一个第三方的URL方案

叫做googlechrome-x-callback

他们是在支持x-callback URL的同时添加这个方案的

这意味着你检查

你的Chrome是否支持x-callback URL

只需要看看它是否可以打开以googlechrome-x-callback开头的URL

如果不能打开也没关系

你只需要还原到基本的Google Chrome URL就行了

如果能打开 那就直接使用这整个URL

我们回到示例程序中

实际尝试这些

现在回到ViewController.m文件

我这里要做的是

对callback URL做些修改

将googlechrome-s开头的URL

改为googlechrome-x-callback

这行快写完了

所以把它移到另一行

好了

现我有三个可用的URL

现在版本的Chrome有我的call back URL

我的基础Chrome URL相当于老版本的Chrome

还有简单的Safari URL

现在我们先回到if语句这里

首先我要检查看看

我能不能打开callback URL

如果可以的话我就可以知道我的Chrome版本

支持x-callback URL方案

因此就可以处理这个URL

帮助我回到我的应用程序

如果不可以的话 我需要添加另外一个判断

好吧 最低要求

你也要能打开chromeURL

如果是的话 我就知道我安装的是另一个版本的Chrome

虽然依然是旧版本的

这样我还是能够用[UIApplication sharApplication]

打开chromeURL

如果你不打开任何一个

那我就知道我没有安装Chrome

我就只能使用Safari了

好了

如果我们再在我的装置运行这个程序

我们可以看到当我们点击这个按钮时会回到Chrome上

Chrome上有按钮指向我的应用程序

那意味着我们是使用的是x-callback版本的URL

而不是Chrome上基础的那一个

这是因为我的Chrome版本

不是两年前的版本

我不能在非常老版本的Chrome上做示范

我也不知道哪里去下载老版本

但是我认为你应该相信我

这样能行

这样是不错 但是我把我的代码从一两行

扩展到了

什么 12行

我们在处理中手动做了一大堆的URL转义

看起来我得将这个逻辑抽象出来

到一个单独的类或者什么的

很幸运的是

Google已经帮我们完成了这些

所以看看下一个

访问GitHub.com/GoogleChrome/OpenInChrome

上的OpenChrome GitHub页面

现在你可以任意下载这些文件

你可以下载ZIP或者直接复制保存到本地

我现在只准备下载ZIP文件

当它下载好了之后我打开它

这里我们要用到的两个文件

是OpenInChromeController.h文件

和OpenInChromeController.m文件

现在我直接拖动这两个文件

到我Xcode的项目中

选择是 复制这些文件

如果你愿意你也可以看看这些文件

如果你是一直跟着课程到现在

你会发现这些代码和你的看起来非常像

它们只是比我们的示例代码更复杂

和严谨一些

所以 去看看吧

你可以查看最重要的头文件

基本上都是这个类的接口

你可以发现它基本是一个单例

我们有一个很好的Bool型方法IsChromeInstalled

我们可以用Chrome打开URL

也可以打开callback URL

回到我们的ViewController

编辑我们按钮的功能函数

基本我们就可以删除这些

我们的努力成果 再见

我要在这里重新定义两个URL

第一个URL是我实际想打开的

命名为pageToOpen等于[NSURL URLWithString]

这只写一个简单的老版的URL

打开的是www.google.com

然后添加我们的第二个URL 也就是callback URL

这应该是googleOpenInChromeExample

同样的 不要忘了末尾的分号

显然要和你的程序相符

现在代码打开它就容易多了

首先 让我们导入

我要添加一个if语句

是说OpenInChromeController

sharedInstance isChromeInstalled 如果是这样

我们让它在Chrome中打开

打开只需要调用

这个URL参数是

你想要打开的页面地址

withCallbackURL就使用callbackURL

createNewTab这个可能不需要

因此我在这里填上No

这格式看起来不错

否则 用户没有安装Chrome

因此我们让它在Safari中打开链接

使用原来的[UIApplication sharedApplication]

openURL方法

这样OpenInChromeController帮我把

从原始URL转换成x-callback URL还有转义等

所有的繁重工作都做了

我们到controller这里

我们要在这里添加一个NSLog声明

显示结束时它实际上试图打开哪个URL

所以在这里我们要添加一个刚刚说的NSLog

输出I am attempting to open

我们就可以查看[ChromeURL absolute string]

我们可以运行来试试

和之前一样 一个按钮

我可以通过点击它进入Chrome

并且这里有一个返回按钮

可以带我回到应用程序上

我们回到我们的控制台上

看看这里发生了些什么

我们可以看到 它把在我们简单的URL

转换到复杂的x-callback URL

这样在Chrome上打开时就会有一个返回按钮

我们停止运行

现在 你可以看到我们复杂的逻辑

转换成了普通的方法

实际应用中 你可以在用户打开应用程序时

判断用户是否安装了Chrome

如果他们已经安装了Chrome

当用户点击链接的时候

你可以弹出一个警报或这是执行一个动作

让他们选择默认浏览器

保存信息在NSUserDefaults中

之后就不用再选择

然后你可以写一个简单的

openURLsInPreferredBrowser方法

使用适当的调用去打开URL

这样就行了

这样就有了一个应用程序

会使用用户自定义的浏览器打开链接

不管浏览器是什么

如果你好奇iOS 8的发展

是否使这个过时了

答案当然是否定的

iOS 8支持大量的扩展

我觉得URL方案的许多用例

或许会被其他扩展更好的解决

但是打开网页的方式目前还不是其中之一

现在我们已经基本

实现了主要的目标

向你展示了怎么在iOS设备用Chrome打开链接

但是我们能用x-callback URL做更多

让我们看看怎么利用

从Chrome返回我们应用的链接吧

下节课中我会告诉你怎么做

所以不要走开

Youtube
Youtube
加入 GDG 字幕组
video_screenshot