SwiftUI Case Study: Presenting from View Controllers

We are happy to announce the release of an iOS sample application that demonstrates how to integrate the Google Mobile Ads SDK into a SwiftUI-based app. This post covers how we implemented full screen ad formats (interstitial, rewarded, rewarded interstitial) in SwiftUI.

The Google Mobile Ads SDK relies heavily on the UIKit Framework, depending on UIView or UIViewController for each ad format. For example, the SDK currently presents full screen ads using the following method:

present(fromRootViewController rootViewController: UIViewController)

In UIKit, ads are typically implemented in a UIViewController, so it is rather trivial to pass in a rootViewController value by simply invoking self. SwiftUI requires us to diverge from this approach, however, because UIViewController cannot be directly referenced in SwiftUI. Since we can’t just pass in self as the root view controller, we needed to achieve a similar result using a SwiftUI-native approach.

Our solution

We created an implementation of the UIViewControllerRepresentable protocol with a UIViewController property. Its one job is to provide access to the UIViewController reference in SwiftUI.

private struct AdViewControllerRepresentable: UIViewControllerRepresentable {
let viewController = UIViewController()

func makeUIViewController(context: Context) -> some UIViewController {
return viewController
}

func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}

AdViewControllerRepresentable needs to be included as part of the view hierarchy even though it holds no significance to the content on screen. This is because canPresent(fromRootViewController:) requires the presenting view controller’s window value to not be nil.

private let adViewControllerRepresentable = AdViewControllerRepresentable()

var body: some View {
Text("hello, friend.")
.font(.largeTitle)
// Add the adViewControllerRepresentable to the background so it
// does not influence the placement of other views in the view hierarchy.
.background {
adViewControllerRepresentable
.frame(width: .zero, height: .zero)
}
}

To present the full screen ads in our sample app, we leveraged action events in SwiftUI.

Button("Watch an ad!") {
coordinator.presentAd(from: adViewControllerRepresentable.viewController)
}

And our AdCoordinator class does the honor of presenting it from our view controller.

private class AdCoordinator: NSObject {
private var ad: GADInterstitialAd?

...

func presentAd(from viewController: UIViewController) {
guard let ad = ad else {
return print("Ad wasn't ready")
}

ad.present(fromRootViewController: viewController)
}
}

And voila!

An alternative option

Instead of creating a UIViewControllerRepresentable, there was always the option to query the rootViewController property from UIWindow.

UIApplication.shared.windows.first?.rootViewController

We decided against this option for the following reasons:

  1. There is the inherent nullability risk to querying an optional array index.
  2. The default value of rootViewController is nil.
  3. If your app utilizes more than one window, the windows array will have multiple elements and therefore, makes querying the “first” window object unreliable.
  4. windows on the UIApplication object is deprecated in iOS 15 and UIWindowScene now holds the reference to this property.

Conclusion

We know there is more than one way to cook an egg when it comes to writing code in SwiftUI. For our use case, we chose the most low-code friendly option. If you have any questions, reach out to our developer forum.

Try it out!

Chrome Beta for Android Update

Hi everyone! We've just released Chrome Beta 108 (108.0.5359.38) for Android. It's now available on Google Play.

You can see a partial list of the changes in the Git log. For details on new features, check out the Chromium blog, and for details on web platform updates, check here.

If you find a new issue, please let us know by filing a bug.

Krishna Govind
Google Chrome

Beta Channel Update for Desktop

The Beta channel has been updated to 108.0.5359.40 for Windows, Mac and Linux .

A full list of changes in this build is available in the log. Interested in switching release channels? Find out how here. If you find a new issues, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues.


Srinivas Sista 

13 surprising ways we’ve collected Street View imagery around the world

You’ve heard of Street View, but have you heard of Sheep View? As un-bahh-lievable as it may sound, these wooly creatures have helped us collect truly ewe-nique Street View imagery. That’s just one of the unexpected ways we’ve added imagery to our Street View collection. Through the years, we’ve captured images on remote islands, along rough terrain and underwater. Since we can’t reach all of those locations by car, we’ve naturally had to get creative. For a peek behind the curtain, here are 13 of the most creative ways we’ve collected Street View imagery — some of which have led to our favorite Street Views ever.

1. By trike

During a coffee run in 2010, one of Google’s senior mechanical engineers spotted a pedi-cab riding through Mountain View. Inspired, he got to talking with the owner, and the Google Trike was born. The Street View Trike allowed Google to map locations that were previously inaccessible to our fleet of cars, making its debut collecting off-road imagery at California's LegoLand. Cyclists rode the modified pedicab in decorative Google jerseys through zoos, landmarks and universities.

A trike with cameras attached parked in front of a cathedral

We developed the Street View Trike to help us access off-road locations.

2. By boat

Next, the team wanted to capture the beauty of the Amazon, but you can’t exactly cycle down the world’s largest river. Our solution was to put the Street View Trike onto a boat and see what happened. We ended up collecting imagery of the Rio Negro, an Amazon Forest trail and five river communities. Weeks after, when program manager Karin Tuxen-Bettman reviewed the footage, she was surprised to find it was partially obscured by a frog that had perched itself on the lens.

“I wasn't aware while it was happening, so there was nothing I could do to change it,” says Karin. “But I was delighted. It represents the unexpected, which we grew to expect on this imagery collection expedition.”

A frog covers the lens of a shot of the Amazon river

A frog landed on the lens during a Street View shoot of the Amazon, showing us it isn’t always smooth sailing.

3. By snorkelers and scuba divers

Boats are great, but what about taking Street View pictures underwater? We’ve done that, too. The ocean covers 71% of the Earth's surface, yet only 5% has been explored. Over the years, our team has partnered with snorkelers and divers to bring underwater imagery to Street View. In ourGoogle Earth collection, you can swim by shipwrecks, reefs and coral gardens across the world.

A diver floats over a coral reef with a camera in hand

Scuba diving and snorkeling allowed us to create underwater images.

4. By snowmobile

Another one of our Street View goals was to make imagery of the ski slopes in Vancouver globally accessible in time for the 2010 Winter Olympics. We achieved this by introducing the Street View Snowmobile. After customizing a snowmobile by attaching a pole-mounted camera, we took to the slopes.

“I am originally from Poland, and I love skiing,” says Magdalena Filak, one of the Googlers leading operations for our Street View Special Collects at the time. “It was so much fun to map the ski resorts with the snowmobile, and then share the captured imagery with my friends and family to plan our skiing trips. The imagery that we captured was just so serene, calm and beautiful.”

A row of snowmobiles, one of which with a camera attached, sit at the base of a ski slope.

There was snow much fun to be had while collecting these cool pictures.

5. By backpack

Even with trikes and snowmobiles, there continued to be locations and landmarks we couldn’t access. That’s where the Street View Trekker came in. Originally introduced in 2012, the first Trekker featured a 360-degree camera system mounted onto a wearable backpack. This allowed wearers to collect images on foot. In 2018, the device got an upgrade with 140-megapixel cameras and laser sensors that can quickly create a digital map of the area.

A man stands on a cliff with a camera mounted backpack, overlooking Machu Picchu

The backpack Trekker provided flexibility and freedom, expanding Street View’s reach.

6. By camel

A camel stands atop a sand dune with a Trekker mounted on its back

The Trekker was fashioned onto a camel, gathering images as the animal walked through the desert.

Yes, you read that right. In order to capture the beauty of the Liwa desert, the Street View Trekker was mounted atop an Arabian one-humped camel, also known as a dromedary. Home to early settlers back in the Late Stone Age, the Liwa desert sand dunes reach a height of up to 131 feet. Using camels for the collection allowed us to collect authentic imagery and minimize our disruption of this fragile environment.

“I had never gone to a desert before, and although I adore animals, I had never been so fortunate to be near a camel,” says Valentina Frassi, a Googler who led some collections for the Middle East and North Africa region at the time. “Dealing with unconventional means of transport, like our stubborn camel friend Raffia, is not an everyday task.”

7. By sheep

A person wearing a camera mounted backpack stands in a field next to sheep

We worked with sheep, the local community and the Street View team to document the Faroe Islands.

Camels aren’t our only fuzzy photographer friends. Home to just 50,000 people, the Faroe Islands are an archipelago in the middle of the North Atlantic Ocean known for having more sheep than human residents. In 2016, a few of those sheep were equipped with solar powered cameras to collect Street View imagery, documenting the local islands.

8. By astronaut

Reaching for the stars, our team partnered with astronaut Thomas Pesquet to give a tour of the International Space Station. Because of the constraints of working in space (and the whole zero gravity thing), Thomas couldn’t use just any equipment. Our team worked with NASA at the Johnson Space Center in Houston and Marshall Space Flight Center in Huntsville, Alabama, to design a gravity-free solution that used DSLR cameras and equipment already on the ISS. Then Thomas sent the pictures down to Earth where we stitched them together to create panoramic 360-degree imagery.

Two people in spacesuits surrounded by assorted equipment and wires shown through Google Street View

We worked with astronaut Thomas Pesquet, NASA and Marshall Space Flight Center to bring Street View to space.

9. By ATV

Made uninhabitable by its rough terrain and polar climate, Devon Island in Canada’s Arctic is an important site for researchers and scientists as its environment is the closest to Mars that can be found without leaving the planet. In 2019, we partnered with Dr. Pascal Lee, chairman of the Mars Institute and director of the Haughton-Mars Project, to get imagery on ATVs of “Mars on Earth.” Just like a trip to Mars, our trip to collect Street View imagery required careful planning and preparation. The team delegated tasks including leading explorations, packing supplies, cooking, handling ATV maintenance and collecting imagery. Dr. Lee’s dog even served as a lookout for polar bears.

10. By raft

Street View imagery taken from a raft in the ocean

Going with the flow, the Street View raft rode the tides of Atol das Rocas.

As part of a partnership with the federal institute for biodiversity in Brazil, ICMBio, we mounted a Street View camera onto a raft and floated out to a ring shaped island, or atoll, that is only accessible to crews with authorization from The Brazilian Navy and ICMBio. According to Tom Nora, a Googler who led the collection team, the raft was a useful solution to one of the team’s biggest challenges: the changing tides that caused the atoll to quickly fill and empty.

“Because of the tide changes, we had to stay in the atoll – which is pretty much an island without clean water – so no shower or sink,” says Tom. “The power on the island, coming from a local solar power plant, was not working. All three people that were living on the island were biologists, so they didn't know how to fix it. Since I'm an electrical engineer and had experience with power electronics, I was able to fix it for them. It was a great win-win situation.”

11. By trolley

We created the Street View Trolley for art lovers with the goal of bringing the world’s most acclaimed museums to Maps. Since we can’t drive the Street View car indoors, our team designed a stable four-wheeled push cart that could bear a heavy load. We equipped it with a panoramic camera to collect 360-degree views, lasers to capture distances to walls, motion sensors to track Trolley’s position, a hard drive to store data and a laptop to operate the system.

12. By rappel

Sometimes the best shots require some extra work, like when New Zealand Googler Matthew Davison came up with the idea of taking a Street View Trekker inside an active volcano. Matthew and a team of explorers rappelled over 1,300 feet into the Marum crater in the South Pacific island nation of Vanuatu, suspending over a molten lava lake the size of two football fields!

“When I came up with the idea, my colleagues thought it was an elaborate prank,” says Matthew, who leads volcano expeditions around the world as a hobby. “When volcanoes aren’t impacting people, they're a beautiful spectacle to look at. Capturing such a rare phenomenon and being able to share it with the world was a huge privilege.” It was also a huge responsibility, Matthew notes: “We had to use specialized heat suits to protect ourselves from the immense heat. Our most important priority was keeping everyone safe.”

13. By model train

We’d traveled far and wide, but a 2016 Street View project in Hamburg, Germany presented a new challenge: shrinking down. The Miniatur Wunderland attraction features the world’s largest model railway with over 42,000 feet of track. Our team partnered with Ubilabs, a data and location technology company, to create our own miniature vehicles that could drive over train tracks and down the streets of the fictional town Knuffingen, one of Miniatur Wunderland’s “theme worlds.” Miniatur Wunderland was crafted with an eye for detail, with thousands of tiny citizens going about their days. Our Street View collection allows you to explore a rowdy Oktoberfest celebration, replicas of several famous landmarks across the world and even some details not visible to museum visitors.

How we designed Chrome to help businesses

Businesses all over the world rely on Chrome to get things done securely and collaboratively — both at home and in the office. And that’s due to the Googlers who work every day to make sure enterprise users stay safe online using Chrome.

We chatted with Robert Shield, a longtime Chrome Googler and the director of engineering on the Chrome Browser Enterprise team, to get an insider’s point of view on how Chrome evolved to become a secure browser for businesses.

Why did Chrome decide to invest in building a browser for businesses?

Early on, we realized that businesses had specific needs for managing Chrome to a large workforce. Shortly after Chrome’s initial launch, we added a variety of enterprise management capabilities like Chrome Browser Cloud Management, and zero trust solutions like BeyondCorp Enterprise, to help with added security controls, distributing software and supporting legacy browsers.

How have businesses’ browser security needs changed over the years?

The way we work has shifted quite drastically, from legacy systems connected over private networks to cloud-centric computing. Workers now need to access data from anywhere and on different types of devices. While this change brings more flexibility and productivity to organizations, it requires them to work even harder to secure their data.

What are some specific requests you get from IT and security professionals using Chrome in modern enterprise environments?

Customers tell us they have a growing need to secure access to data hosted in the cloud, so we provide tools to prevent data loss right in the browser. We also make it easy for businesses to integrate Chrome with popular security solution providers, like Splunk, CrowdStrike and Palo Alto Networks. This allows customers to gain a deeper understanding of potentially harmful threats their users face on the web and be more proactive in their remediation efforts.

What are you working on that excites you most?

We’re really focused on helping businesses safeguard their whole computing stack, from cloud services to the desktops, laptops and phones used by workers. With the move to cloud workloads accelerating over the coming years, we’re investing in tighter integrations between Chrome and the full slate of security tools and services that organizations use every day to provide complete end-to-end security for users and data. It’s exciting to see the browser evolve to play an active role in securing business environments.

Source: Google Chrome


Open Source Pass Converter for Mobile Wallets

Posted by Stephen McDonald, Developer Programs Engineer, and Nick Alteen, Technical Writer, Engineering, Wallet

Each of the mobile wallet apps implement their own technical specification for passes that can be saved to the wallet. Pass structure and configuration varies by both the wallet application and the specific type of pass, meaning developers have to build and maintain code bases for each platform.

As part of Developer Relations for Google Wallet, our goal is to make life easier for those who want to integrate passes into their mobile or web applications. Today, we're excited to release the open-source Pass Converter project. The Pass Converter lets you take existing passes for one wallet application, convert them, and make them available in your mobile or web application for another wallet platform.

Moving image of Pass Converter successfully converting an external pkpass file to a Google Wallet pass

The Pass Converter launches with support for Google Wallet and Apple Wallet apps, with plans to add support for others in the future. For example, if you build an event ticket pass for one wallet, you can use the converter to automatically create a pass for another wallet. The following list of pass types are supported for their respective platforms:

  • Event tickets
  • Generic passes
  • Loyalty/Store cards
  • Offers/Coupons
  • Flight/Boarding passes
  • Other transit passes

We designed the Pass Converter with flexibility in mind. The following features provide additional customization to your needs.

  • hints.json file can be provided to the Pass Converter to map Google Wallet pass properties to custom properties in other passes.
  • For pass types that require certificate signatures, you can simply generate the pass structure and hand it off to your existing signing process
  • Since images in Google Wallet passes are referenced by URLs, the Pass Converter can host the images itself, store them in Google Cloud Storage, or send them to another image host you manage.

If you want to quickly test converting different passes, the Pass Converter includes a demo mode where you can load a simple webpage to test converting passes. Later, you can run the tool via the command line to convert existing passes you manage. When you’re ready to automate pass conversion, the tool can be run as a web service within your environment.

The following command provides a demo web page on http://localhost:3000 to test converting passes.

node app.js demo

The next command converts passes locally. If the output path is omitted, the Pass Converter will output JSON to the terminal (for PKPass files, this will be the contents of pass.json).

node app.js <pass input path> <pass output path>

Lastly, the following command runs the Pass Converter as a web service. This service accepts POST requests to the root URL (e.g. https://localhost:3000/) with multipart/form-data encoding. The request body should include a single pass file.

node app.js


Ready to get started? Check out the GitHub repository where you can try converting your own passes. We welcome contributions back to the project as well!

Extended Stable Channel Update for Desktop

 The Extended Stable channel has been updated to 106.0.5249.181 for Windows and Mac which will roll out over the coming days/weeks.

A full list of changes in this build is available in the log. Interested in switching release channels? Find out how here. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues.


Srinivas Sista
Google Chrome

Recommendations in Google Ads API Roundup

Google Ads API now supports 25 different recommendation types including the most frequently used types. With the wide array of types available and documentation with examples to help you get started, there has never been a better time to get started retrieving and applying recommendations with Google Ads API!

Key suggested uses
Recommendations provide customized suggestions to help increase your campaigns' performance. Recommendations can introduce you to new, relevant features, help you get more out of your budget by improving your bidding, keywords, and ads, and can increase the overall performance and efficiency of your campaigns. Here are a few examples of how recommendations can help with the management of your account:
  • Avoid getting limited by budget this holiday season. With CAMPAIGN_BUDGET and FORECASTING_CAMPAIGN_BUDGET recommendation types you’ll be sure to keep your ads running, so potential customers can see them by preventing your campaign from under-performing due to a limited budget.
  • Expand the reach of your ads with USE_BROAD_MATCH_KEYWORD, which will update your keyword match types to show your ads to relevant potential customers.
  • Upgrade to Performance Max with UPGRADE_SMART_SHOPPING_CAMPAIGN_TO_PERFORMANCE_MAX and UPGRADE_LOCAL_CAMPAIGN_TO_PERFORMANCE_MAX, which will take care of migrating your existing Smart Shopping and Local Campaigns for you.
Implementation guide
To help you get started, check out our implementation guide and YouTube deep dive tutorial for tips.

Code examples
We’ve also put together these code examples to save you time getting up to speed with Recommendations in Google Ads API.

Activate your first-party data on connected TV

With total streaming usage taking 36% of overall TV share, you can be sure to find your audience on connected TV (CTV). We’re committed to helping you deliver high quality ad experiences to all streamers by bringing the best of digital ad technology — like delivering the right message to the right audience — to the TV screen. That’s why earlier this year, we introduced Google Audiences to CTV campaigns in Display & Video 360.

Successful businesses lean into existing customer relationships and the information they willingly share to drive performance. This information, known as first-party data, can be the basis for privacy-preserving, future-proofed ways to connect with customers. Today we’re announcing new features to let you reach your first-party audience on CTV devices and automatically find more users who look like your core audience.

Engage with people you know as they watch CTV in the U.S.

First, we’re making it possible for you to engage with your first-party audiences on connected TV devices. Now, when you select a first-party audience list for your Display and Video 360 campaign, the list will automatically be eligible to reach your most engaged customers as they stream connected TV content. This is an easy and effective way to ensure you reach people who already have a connection with your brand, on the device that they are using at the moment.

Let’s say you’re a cosmetic brand preparing for the holiday season and want to build on the direct relationship you have with customers who have downloaded your app. With Display & Video 360, you can now reach this first-party audience as they’re streaming their favorite shows on Disney, Tubi, or other premium publishers.

It’s easy to benefit from this new capability. All you have to do is select and add your first-party audience to your insertion order or line-item, in the same way you would have done for web and mobile devices. Display & Video 360 will automatically start reaching people who have an existing relationship with your brand when they are watching on CTV. This feature is available now to all advertisers in the United States, you can learn more about how it works by visiting our help center.

Reach more streamers similar to your first-party audience around the world

Once you have engaged with your first-party audience, reaching additional people who have similar behaviors or characteristics to your core audiences helps you boost campaign performance.

We are also launching audience expansion for CTV. Audience expansion makes it easy to reach more people that matter to your business and achieve your marketing goals. By utilizing contextual and geo signals, Display and Video 360’s algorithm will create a model to find CTV streamers who are similar to your core audience.

Let’s go back to the example of the beauty brand trying to reach relevant seasonal shoppers. You could now apply audience expansion to your first-party audience and show CTV ads to streamers who are similar to those who have downloaded your app.

You’ll be able to activate audience expansion across all regions globally in Display and Video 360 early next year via controls available in Display & Video 360’s TV insertion order.

These new features are just some of the ways we’re helping businesses connect with their most engaged audience while respecting people’s privacy. As we invent fundamentally new audience solutions, we’ll ensure they seamlessly work on CTV and allow you to make the most of the streaming boom.

A new way to control and optimize frequency on YouTube

Achieving the right video ad frequency for both viewers and advertisers has always been a juggling act.

That challenge has only increased as linear TV viewership in the US has dropped from 100 million households in 2014 to a forecast of just 44 million by 2025. As reach declines, the number of times the audience sees an ad on TV is increasing. Seeing the same ad repeatedly can be a frustrating experience for viewers and proves wasteful for advertisers. On average, TV advertisers’ return on investment (ROI) decreased by 41% when frequency exceeded 6+ weekly impressions — which represents 46% of TV impressions served, according to a MMM meta analysis commissioned with Nielsen[539a59].

Almost half of the linear TV impressions in our study were considered waste but the same study from Nielsen shows that brands can increase their average weekly frequency from one to three on YouTube with a consistent ROI[78a842]. This is a huge opportunity for marketers to maximize their impact across the same set of people they are already reaching today.

At YouTube, we are helping advertisers deliver a better advertising experience for viewers without any compromise in ROI. Based on this commitment, earlier this year we announced our frequency management solution on Display and Video 360 that allows marketers to manage the number of times people see their ads across YouTube and third-party networks. We’re now taking that a step further to revolutionize reach and frequency-buying on YouTube.

To help marketers harness this impact, we’re announcing the launch of Target frequency globally for YouTube campaigns. This will help advertisers optimize towards more precise reach and frequency, while ensuring that we continue to provide a suitable advertising experience for viewers. Target frequency allows advertisers to select a frequency goal of up to four per week and our systems will optimize towards maximum unique reach at that desired frequency.

We recently partnered with Triscuit to see how the brand can drive incremental impact to its reach campaigns with a frequency target. Triscuit's goal was to ensure that the brand stays top-of-mind with the consumer. The brand set up a Video experiment to determine the incremental ad recall that a weekly frequency of two could deliver. The Target frequency campaign achieved a 93% higher absolute ad recall lift compared to the non-frequency optimized campaign, at a 40% cheaper cost per lifted user.

We're committed to improving the advertising experience for brands and viewers

Now advertisers can select the frequency target and our systems will optimize towards maximum unique reach at the frequency goal. With our built-in capping, campaigns deliver within a tight distribution range so viewers don’t see the ads too many times. In fact, over 95% of Target frequency campaigns on YouTube successfully achieved their frequency goals when set up following recommended best practices.[162fd8]Not only do the campaigns deliver on their target frequency, but they drive brand impact as well.

To start using a frequency optimized campaign, create a new video reach campaign with the Target frequency goal and select the desired weekly frequency.