├── .github └── workflows │ └── canonical-gradle.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── Gemfile ├── Gemfile.lock ├── ISSUE_TEMPLATE.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── analytics │ ├── .gitignore │ ├── README.md │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── analytics-sample.png │ │ │ ├── java │ │ │ └── com │ │ │ │ └── google │ │ │ │ └── samples │ │ │ │ └── quickstart │ │ │ │ └── analytics │ │ │ │ ├── AnalyticsApplication.java │ │ │ │ ├── ImageFragment.java │ │ │ │ ├── ImageInfo.java │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ ├── face.png │ │ │ ├── favorite.png │ │ │ ├── flash.png │ │ │ └── whitebalance.png │ │ │ ├── drawable-mdpi │ │ │ ├── face.png │ │ │ ├── favorite.png │ │ │ ├── flash.png │ │ │ └── whitebalance.png │ │ │ ├── drawable-xhdpi │ │ │ ├── face.png │ │ │ ├── favorite.png │ │ │ ├── flash.png │ │ │ └── whitebalance.png │ │ │ ├── drawable-xxhdpi │ │ │ ├── face.png │ │ │ ├── favorite.png │ │ │ ├── flash.png │ │ │ └── whitebalance.png │ │ │ ├── drawable │ │ │ └── circle.xml │ │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ └── fragment_main.xml │ │ │ ├── menu │ │ │ └── main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ │ └── xml │ │ │ └── global_tracker.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── build.gradle ├── gcm │ ├── .gitignore │ ├── README.md │ ├── app │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── gcm │ │ │ │ └── play │ │ │ │ └── android │ │ │ │ └── samples │ │ │ │ └── com │ │ │ │ └── gcmquickstart │ │ │ │ └── MainActivityEspressoTest.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── gcm-sample.png │ │ │ ├── java │ │ │ └── gcm │ │ │ │ └── play │ │ │ │ └── android │ │ │ │ └── samples │ │ │ │ └── com │ │ │ │ └── gcmquickstart │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MyGcmListenerService.java │ │ │ │ ├── MyInstanceIDListenerService.java │ │ │ │ ├── QuickstartPreferences.java │ │ │ │ └── RegistrationIntentService.java │ │ │ └── res │ │ │ ├── drawable-hdpi-v11 │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-hdpi │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-mdpi-v11 │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-xhdpi-v11 │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-xxhdpi-v11 │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_stat_ic_notification.png │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-v21 │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gcmsender │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── gcm │ │ │ └── play │ │ │ └── android │ │ │ └── samples │ │ │ └── com │ │ │ └── gcmsender │ │ │ └── GcmSender.java │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── signin │ ├── .gitignore │ ├── .google │ └── packaging.yml │ ├── README.md │ ├── app │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── samples │ │ │ └── quickstart │ │ │ └── signin │ │ │ ├── ChooserActivity.java │ │ │ ├── IdTokenActivity.java │ │ │ ├── RestApiActivity.java │ │ │ ├── ServerAuthCodeActivity.java │ │ │ ├── SignInActivity.java │ │ │ └── SignInActivityWithDrive.java │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── googleg_color.png │ │ ├── drawable-mdpi │ │ │ └── googleg_color.png │ │ ├── drawable-xhdpi │ │ │ └── googleg_color.png │ │ ├── drawable-xxhdpi │ │ │ └── googleg_color.png │ │ ├── drawable │ │ │ └── ic_launcher_big.png │ │ ├── layout │ │ │ ├── activity_chooser.xml │ │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values-land │ │ │ └── dimens.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── sign-in-sample.png │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle └── ios ├── analytics ├── AnalyticsExample.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── AnalyticsExample.xcscheme │ │ └── AnalyticsExampleSwift.xcscheme ├── AnalyticsExample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── CircleImageView.h │ ├── CircleImageView.m │ ├── Info.plist │ ├── PatternTabBarController.h │ ├── PatternTabBarController.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── AnalyticsExampleSwift │ ├── AppDelegate.swift │ ├── BridgingHeader.h │ ├── PatternTabBarController.swift │ └── ViewController.swift ├── AnalyticsExampleTests │ ├── AppTests.m │ ├── LogWrapper.h │ └── LogWrapper.mm ├── Images │ └── AnalyticsImages.xcassets │ │ ├── Contents.json │ │ ├── favorite.imageset │ │ ├── Contents.json │ │ ├── favorite.png │ │ ├── favorite_2x.png │ │ └── favorite_3x.png │ │ ├── flash_on.imageset │ │ ├── Contents.json │ │ ├── flash_on.png │ │ ├── flash_on_2x.png │ │ └── flash_on_3x.png │ │ ├── icon-favorite.imageset │ │ ├── Contents.json │ │ ├── icon-favorite.png │ │ ├── icon-favorite_2x-1.png │ │ └── icon-favorite_3x.png │ │ ├── icon-flash_on.imageset │ │ ├── Contents.json │ │ ├── icon-flash_on.png │ │ ├── icon-flash_on_2x.png │ │ └── icon-flash_on_3x.png │ │ ├── icon-tag_faces.imageset │ │ ├── Contents.json │ │ ├── icon-tag_faces.png │ │ ├── icon-tag_faces_2x.png │ │ └── icon-tag_faces_3x.png │ │ ├── icon-wb_incandescent.imageset │ │ ├── Contents.json │ │ ├── icon-wb_incandescent.png │ │ ├── icon-wb_incandescent_2x.png │ │ └── icon-wb_incandescent_3x.png │ │ ├── tag_faces.imageset │ │ ├── Contents.json │ │ ├── tag_faces.png │ │ ├── tag_faces_2x.png │ │ └── tag_faces_3x.png │ │ └── wb_incandescent.imageset │ │ ├── Contents.json │ │ ├── wb_incandescent.png │ │ ├── wb_incandescent_2x.png │ │ └── wb_incandescent_3x.png ├── Podfile ├── README.md └── Screenshot │ └── analytics-sample.png ├── gcm ├── GcmExample.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── GcmExample.xcscheme │ │ └── GcmExampleSwift.xcscheme ├── GcmExample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── GcmExampleSwift │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── Main.storyboard │ └── ViewController.swift ├── GcmExampleTests │ ├── GcmExampleTests.m │ └── Info.plist ├── GcmServerDemo │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── MasterViewController.swift │ └── MasterViewController.xib ├── Podfile ├── README.md └── Screenshot │ └── gcm-sample.png ├── shared ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── AppIcon-60-2x.png │ │ ├── AppIcon-60-3x.png │ │ ├── AppIcon-76-2x.png │ │ ├── AppIcon-76.png │ │ └── Contents.json │ ├── Contents.json │ ├── Icon.imageset │ │ ├── Contents.json │ │ └── Icon.png │ ├── LaunchImage.launchimage │ │ ├── Contents.json │ │ ├── Default-568h_2x.png │ │ ├── Default-Landscape_2x~ipad.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait_2x~ipad.png │ │ ├── Default-Portrait~ipad.png │ │ └── Default_2x.png │ ├── Logo.imageset │ │ ├── Contents.json │ │ └── FriendlyPing-Logo.png │ └── Watermark.imageset │ │ ├── Contents.json │ │ └── FriendlyPing-Watermark.png └── LaunchScreen.xib ├── signin ├── .gitignore ├── Default-568h@2x.png ├── Podfile ├── README.md ├── Screenshot │ └── sign-in-sample.png ├── SignInExample.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── SignInExample.xcscheme │ │ └── SignInExampleSwift.xcscheme ├── SignInExample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── appbg.png │ ├── en.lproj │ │ └── Main.strings │ └── main.m ├── SignInExampleSwift │ ├── AppDelegate.swift │ └── ViewController.swift └── SignInExampleTests │ ├── Info.plist │ └── SignInExampleTests.m └── test.sh /.github/workflows/canonical-gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Build Canonical Sample App 5 | 6 | on: 7 | push: 8 | branches: [ summer-2020 ] 9 | pull_request: 10 | branches: [ summer-2020 ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up JDK 1.8 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: 1.8 23 | - name: Switch to canonical project 24 | run: cd android/canonical/ 25 | - name: Grant execute permission for gradlew 26 | run: chmod +x gradlew 27 | - name: Build with Gradle 28 | run: ./gradlew build 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # iOS 2 | .DS_Store 3 | Pods/ 4 | Podfile.lock 5 | xcuserdata/ 6 | *.xcworkspace/ 7 | 8 | # Android 9 | google-services.json 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode10.3 2 | language: objective-c 3 | cache: 4 | - bundler 5 | - cocoapods 6 | 7 | podfile: ios/analytics/Podfile 8 | env: SAMPLE=Analytics 9 | 10 | matrix: 11 | include: 12 | - podfile: ios/signin/Podfile 13 | env: SAMPLE=SignIn 14 | 15 | rvm: 2.6.0 16 | before_install: 17 | - gem install bundler 18 | - cd ios/$SAMPLE 19 | - bundle install 20 | - gem install xcpretty 21 | - bundle exec pod install --repo-update 22 | - sed -i '' 's/YOUR_REVERSED_CLIENT_ID/com.googleusercontent.apps.123456789000-hjugbg6ud799v4c49dim8ce2usclthar/' "$SAMPLE"Example/Info.plist 23 | - cd - 24 | 25 | script: ios/test.sh 26 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # How to become a contributor and submit your own code 3 | 4 | ## Contributor License Agreements 5 | 6 | We'd love to accept your sample apps and patches! Before we can take them, we 7 | have to jump a couple of legal hurdles. 8 | 9 | Please fill out either the individual or corporate Contributor License Agreement 10 | (CLA). 11 | 12 | * If you are an individual writing original source code and you're sure you 13 | own the intellectual property, then you'll need to sign an 14 | [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). 15 | * If you work for a company that wants to allow you to contribute your work, 16 | then you'll need to sign a 17 | [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). 18 | 19 | Follow either of the two links above to access the appropriate CLA and 20 | instructions for how to sign and return it. Once we receive it, we'll be able to 21 | accept your pull requests. 22 | 23 | ## Contributing a Patch 24 | 25 | 1. Sign a Contributor License Agreement, if you have not yet done so (see 26 | details above). 27 | 1. Create your change to the repo in question. 28 | * Fork the desired repo, develop and test your code changes. 29 | * Ensure that your code is clear and comprehensible. 30 | * Ensure that your code has an appropriate set of unit tests which all pass. 31 | 1. Submit a pull request. 32 | 1. The repo owner will review your request. If it is approved, the change will 33 | be merged. If it needs additional work, the repo owner will respond with 34 | useful comments. 35 | 36 | ## Contributing a New Sample App 37 | 38 | 1. Sign a Contributor License Agreement, if you have not yet done so (see 39 | details above). 40 | 1. Create your own repo for your app following this naming convention: 41 | * mirror-{app-name}-{language or platform} 42 | * apps: quickstart, photohunt-server, photohunt-client 43 | * example: mirror-quickstart-android 44 | * For multi-language apps, concatenate the primary languages like this: 45 | mirror-photohunt-server-java-python. 46 | 47 | 1. Create your sample app in this repo. 48 | * Be sure to clone the README.md, CONTRIBUTING.md and LICENSE files from the 49 | googlecast repo. 50 | * Ensure that your code is clear and comprehensible. 51 | * Ensure that your code has an appropriate set of unit tests which all pass. 52 | * Instructional value is the top priority when evaluating new app proposals for 53 | this collection of repos. 54 | 1. Submit a request to fork your repo in googlesamples organization. 55 | 1. The repo owner will review your request. If it is approved, the sample will 56 | be merged. If it needs additional work, the repo owner will respond with 57 | useful comments. 58 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | 2 | source 'https://rubygems.org' 3 | 4 | gem 'cocoapods', :git => 'https://github.com/CocoaPods/CocoaPods.git' 5 | gem 'cocoapods-core', :git => 'https://github.com/CocoaPods/Core.git' 6 | gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj.git' 7 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/CocoaPods/CocoaPods.git 3 | revision: af83e4713771bc98dd7f903cc81c4fbc8866812c 4 | specs: 5 | cocoapods (1.8.0.beta.1) 6 | activesupport (>= 4.0.2, < 5) 7 | claide (>= 1.0.2, < 2.0) 8 | cocoapods-core (= 1.8.0.beta.1) 9 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 10 | cocoapods-downloader (>= 1.2.2, < 2.0) 11 | cocoapods-plugins (>= 1.0.0, < 2.0) 12 | cocoapods-search (>= 1.0.0, < 2.0) 13 | cocoapods-stats (>= 1.0.0, < 2.0) 14 | cocoapods-trunk (>= 1.3.1, < 2.0) 15 | cocoapods-try (>= 1.1.0, < 2.0) 16 | colored2 (~> 3.1) 17 | escape (~> 0.0.4) 18 | fourflusher (>= 2.3.0, < 3.0) 19 | gh_inspector (~> 1.0) 20 | molinillo (~> 0.6.6) 21 | nap (~> 1.0) 22 | ruby-macho (~> 1.4) 23 | xcodeproj (>= 1.11.1, < 2.0) 24 | 25 | GIT 26 | remote: https://github.com/CocoaPods/Core.git 27 | revision: 0a6dea961da236995dfde3c7927e4daaf2045820 28 | specs: 29 | cocoapods-core (1.8.0.beta.1) 30 | activesupport (>= 4.0.2, < 6) 31 | algoliasearch (~> 1.0) 32 | concurrent-ruby (~> 1.0) 33 | fuzzy_match (~> 2.0.4) 34 | nap (~> 1.0) 35 | 36 | GIT 37 | remote: https://github.com/CocoaPods/Xcodeproj.git 38 | revision: 602c802125b69199ccb06094974a569a98e734c3 39 | specs: 40 | xcodeproj (1.12.0) 41 | CFPropertyList (>= 2.3.3, < 4.0) 42 | atomos (~> 0.1.3) 43 | claide (>= 1.0.2, < 2.0) 44 | colored2 (~> 3.1) 45 | nanaimo (~> 0.2.6) 46 | 47 | GEM 48 | remote: https://rubygems.org/ 49 | specs: 50 | CFPropertyList (3.0.0) 51 | activesupport (4.2.11.1) 52 | i18n (~> 0.7) 53 | minitest (~> 5.1) 54 | thread_safe (~> 0.3, >= 0.3.4) 55 | tzinfo (~> 1.1) 56 | algoliasearch (1.26.1) 57 | httpclient (~> 2.8, >= 2.8.3) 58 | json (>= 1.5.1) 59 | atomos (0.1.3) 60 | claide (1.0.3) 61 | cocoapods-deintegrate (1.0.4) 62 | cocoapods-downloader (1.6.3) 63 | cocoapods-plugins (1.0.0) 64 | nap 65 | cocoapods-search (1.0.0) 66 | cocoapods-stats (1.1.0) 67 | cocoapods-trunk (1.3.1) 68 | nap (>= 0.8, < 2.0) 69 | netrc (~> 0.11) 70 | cocoapods-try (1.1.0) 71 | colored2 (3.1.2) 72 | concurrent-ruby (1.1.5) 73 | escape (0.0.4) 74 | fourflusher (2.3.1) 75 | fuzzy_match (2.0.4) 76 | gh_inspector (1.1.3) 77 | httpclient (2.8.3) 78 | i18n (0.9.5) 79 | concurrent-ruby (~> 1.0) 80 | json (2.2.0) 81 | minitest (5.11.3) 82 | molinillo (0.6.6) 83 | nanaimo (0.2.6) 84 | nap (1.1.0) 85 | netrc (0.11.0) 86 | ruby-macho (1.4.0) 87 | thread_safe (0.3.6) 88 | tzinfo (1.2.10) 89 | thread_safe (~> 0.1) 90 | 91 | PLATFORMS 92 | ruby 93 | 94 | DEPENDENCIES 95 | cocoapods! 96 | cocoapods-core! 97 | xcodeproj! 98 | 99 | BUNDLED WITH 100 | 2.0.2 101 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Step 1: Are you in the right place? 2 | 3 | * For issues or feature requests related to the code **in this repository** file a Github issue. 4 | * For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/) tagged appropriately. 5 | 6 | ### Step 2: Describe your environment 7 | 8 | * Device: _____ 9 | * OS version: _____ 10 | * SDK version: _____ 11 | * [Android] Google Play Services version: _____ 12 | 13 | ### Step 3: Describe the problem: 14 | 15 | #### Steps to reproduce: 16 | 17 | 1. _____ 18 | 2. _____ 19 | 3. _____ 20 | 21 | #### Observed Results: 22 | 23 | * What happened? This could be a description, log output, etc. 24 | 25 | #### Expected Results: 26 | 27 | * What did you expect to happen? 28 | 29 | #### Relevant Code: 30 | 31 | ``` 32 | // TODO(you): code here to reproduce the problem 33 | ``` 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google APIs for Mobile: Quickstarts 2 | 3 | A collection of quickstart samples demonstrating the Google APIs for 4 | [Android](https://developers.google.com/android) and [iOS](https://developers.google.com/ios). 5 | 6 | ## How to make contributions? 7 | Please read and follow the steps in the [CONTRIBUTING.md](CONTRIBUTING.md) 8 | 9 | [![Build Status](https://travis-ci.org/googlesamples/google-services.svg?branch=master)](https://travis-ci.org/googlesamples/google-services) 10 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea/ 3 | *.iml 4 | build/ 5 | /local.properties 6 | .DS_Store 7 | /captures 8 | google-services.json 9 | -------------------------------------------------------------------------------- /android/analytics/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | .DS_Store 4 | build/ 5 | 6 | # Android Studio 7 | .idea 8 | *.iml 9 | -------------------------------------------------------------------------------- /android/analytics/README.md: -------------------------------------------------------------------------------- 1 | Google Analytics Quickstart 2 | =========================== 3 | 4 | Google Analytics Android Quickstart app demonstrates collecting 5 | app usage analytics via [Tracker](https://developer.android.com/reference/com/google/android/gms/analytics/Tracker.html) 6 | available in Google Play Services. HitBuilders.ScreenViewBuilder is used to 7 | send screen view analytics. 8 | 9 | Introduction 10 | ------------ 11 | 12 | - [Read more about Google Analytics](https://developers.google.com/analytics/) 13 | 14 | Getting Started 15 | --------------- 16 | 17 | - Follow the [quickstart guide](https://developers.google.com/analytics/devguides/collection/android/v4/start) 18 | to set up your project in Android Studio. 19 | - Make sure to replace `ga_trackingId` in `res/xml/global_tracker.xml` 20 | with your Google Analytics tracking ID. 21 | - Run the sample on your Android device or emulator. 22 | - Swipe between images to register screen views. 23 | - View collected analytics via [Google Analytics](https://www.google.com/analytics/web). 24 | 25 | Screenshots 26 | ----------- 27 | ![Screenshot](app/src/main/analytics-sample.png) 28 | 29 | Support 30 | ------- 31 | 32 | - Stack Overflow: http://stackoverflow.com/questions/tagged/google-analytics 33 | 34 | If you've found an error in this sample, please file an issue: 35 | https://github.com/googlesamples/google-services/issues 36 | 37 | Patches are encouraged, and may be submitted by forking this project and 38 | submitting a pull request through GitHub. 39 | 40 | License 41 | ------- 42 | 43 | Copyright 2015 Google, Inc. 44 | 45 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 46 | license agreements. See the NOTICE file distributed with this work for 47 | additional information regarding copyright ownership. The ASF licenses this 48 | file to you under the Apache License, Version 2.0 (the "License"); you may not 49 | use this file except in compliance with the License. You may obtain a copy of 50 | the License at 51 | 52 | http://www.apache.org/licenses/LICENSE-2.0 53 | 54 | Unless required by applicable law or agreed to in writing, software 55 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 56 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 57 | License for the specific language governing permissions and limitations under 58 | the License. 59 | -------------------------------------------------------------------------------- /android/analytics/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | buildToolsVersion '27.0.2' 6 | 7 | defaultConfig { 8 | applicationId "com.google.samples.quickstart.analytics" 9 | minSdkVersion 14 10 | targetSdkVersion 27 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt') 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation 'com.android.support:appcompat-v7:27.1.0' 24 | implementation 'com.android.support:design:27.1.0' 25 | implementation 'com.android.support:support-v4:27.1.0' 26 | 27 | // [START gms_compile] 28 | implementation 'com.google.android.gms:play-services-analytics:15.0.0' 29 | // [END gms_compile] 30 | } 31 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/analytics-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/analytics-sample.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/java/com/google/samples/quickstart/analytics/AnalyticsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.samples.quickstart.analytics; 18 | 19 | import android.app.Application; 20 | 21 | import com.google.android.gms.analytics.GoogleAnalytics; 22 | import com.google.android.gms.analytics.Tracker; 23 | 24 | /** 25 | * This is a subclass of {@link Application} used to provide shared objects for this app, such as 26 | * the {@link Tracker}. 27 | */ 28 | public class AnalyticsApplication extends Application { 29 | 30 | private static GoogleAnalytics sAnalytics; 31 | private static Tracker sTracker; 32 | 33 | @Override 34 | public void onCreate() { 35 | super.onCreate(); 36 | 37 | sAnalytics = GoogleAnalytics.getInstance(this); 38 | } 39 | 40 | /** 41 | * Gets the default {@link Tracker} for this {@link Application}. 42 | * @return tracker 43 | */ 44 | synchronized public Tracker getDefaultTracker() { 45 | // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG 46 | if (sTracker == null) { 47 | sTracker = sAnalytics.newTracker(R.xml.global_tracker); 48 | } 49 | 50 | return sTracker; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/java/com/google/samples/quickstart/analytics/ImageFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.samples.quickstart.analytics; 18 | 19 | 20 | import android.os.Bundle; 21 | import android.support.v4.app.Fragment; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.widget.ImageView; 26 | 27 | 28 | /** 29 | * This fragment displays a featured, specified image. 30 | */ 31 | public class ImageFragment extends Fragment { 32 | private static final String ARG_PATTERN = "pattern"; 33 | 34 | private int resId; 35 | 36 | /** 37 | * Create a {@link ImageFragment} displaying the given image. 38 | * 39 | * @param resId to display as the featured image 40 | * @return a new instance of {@link ImageFragment} 41 | */ 42 | public static ImageFragment newInstance(int resId) { 43 | ImageFragment fragment = new ImageFragment(); 44 | Bundle args = new Bundle(); 45 | args.putInt(ARG_PATTERN, resId); 46 | fragment.setArguments(args); 47 | return fragment; 48 | } 49 | 50 | public ImageFragment() { 51 | } 52 | 53 | @Override 54 | public void onCreate(Bundle savedInstanceState) { 55 | super.onCreate(savedInstanceState); 56 | if (getArguments() != null) { 57 | resId = getArguments().getInt(ARG_PATTERN); 58 | } 59 | } 60 | 61 | @Override 62 | public View onCreateView(LayoutInflater inflater, 63 | ViewGroup container, 64 | Bundle savedInstanceState) { 65 | View view = inflater.inflate(R.layout.fragment_main, container, false); 66 | ImageView imageView = (ImageView) view.findViewById(R.id.imageView); 67 | imageView.setImageResource(resId); 68 | 69 | return view; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/java/com/google/samples/quickstart/analytics/ImageInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.samples.quickstart.analytics; 18 | 19 | /** 20 | * Pair of resource IDs representing an image and its title. 21 | */ 22 | public class ImageInfo { 23 | 24 | public final int image; 25 | public final int title; 26 | 27 | /** 28 | * Create a new ImageInfo. 29 | * @param image resource of image 30 | * @param title resource of title 31 | */ 32 | public ImageInfo(int image, int title) { 33 | this.image = image; 34 | this.title = title; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-hdpi/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-hdpi/face.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-hdpi/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-hdpi/favorite.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-hdpi/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-hdpi/flash.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-hdpi/whitebalance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-hdpi/whitebalance.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-mdpi/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-mdpi/face.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-mdpi/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-mdpi/favorite.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-mdpi/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-mdpi/flash.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-mdpi/whitebalance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-mdpi/whitebalance.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xhdpi/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xhdpi/face.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xhdpi/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xhdpi/favorite.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xhdpi/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xhdpi/flash.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xhdpi/whitebalance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xhdpi/whitebalance.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xxhdpi/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xxhdpi/face.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xxhdpi/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xxhdpi/favorite.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xxhdpi/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xxhdpi/flash.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable-xxhdpi/whitebalance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/drawable-xxhdpi/whitebalance.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/drawable/circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 15 | 21 | 22 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 15 | 24 | 25 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 64dp 17 | 18 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 16dp 17 | 16dp 18 | 19 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | Analytics Quickstart 17 | A 18 | B 19 | C 20 | D 21 | Share 22 | 23 | Please configure global_tracker.xml, see README. 24 | 25 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android/analytics/app/src/main/res/xml/global_tracker.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | REPLACE_ME 4 | 5 | -------------------------------------------------------------------------------- /android/analytics/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | maven { url 'https://maven.google.com' } 7 | mavenLocal() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | jcenter() 17 | mavenLocal() 18 | maven { url 'https://maven.google.com' } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /android/analytics/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /android/analytics/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/analytics/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/analytics/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip 6 | -------------------------------------------------------------------------------- /android/analytics/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/analytics/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | mavenLocal() 5 | maven { url 'https://maven.google.com' } 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.0.1' 9 | classpath 'com.google.gms:google-services:3.3.0' 10 | } 11 | } 12 | 13 | plugins { 14 | id 'com.github.ben-manes.versions' version '0.17.0' 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | //mavenLocal() must be listed at the top to facilitate testing 20 | mavenLocal() 21 | jcenter() 22 | maven { url 'https://maven.google.com' } 23 | maven { url 'https://maven.fabric.io/public' } 24 | } 25 | 26 | // See: https://github.com/ben-manes/gradle-versions-plugin 27 | dependencyUpdates.resolutionStrategy = { 28 | componentSelection { rules -> 29 | rules.all { selection -> 30 | boolean numbersOnly = (/^[\d.]+$/ ==~ selection.candidate.version) 31 | if (!numbersOnly) { 32 | selection.reject("Rejecting: ${selection.candidate.version}") 33 | } 34 | } 35 | } 36 | } 37 | } 38 | 39 | task clean(type: Delete) { 40 | delete rootProject.buildDir 41 | } 42 | -------------------------------------------------------------------------------- /android/gcm/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea/ 3 | *.iml 4 | build/ 5 | /local.properties 6 | .DS_Store 7 | /captures 8 | google-services.json 9 | -------------------------------------------------------------------------------- /android/gcm/README.md: -------------------------------------------------------------------------------- 1 | Google Cloud Messaging Quickstart 2 | ================================= 3 | 4 | Google Cloud Messaging Android Quickstart app demonstrates registering 5 | an Android app for GCM and handling the receipt of a GCM message. 6 | InstanceID allows easy registration while GcmReceiver and 7 | GcmListenerService provide simple means of receiving and handling 8 | messages. 9 | 10 | Introduction 11 | ------------ 12 | 13 | - [Read more about Google Cloud Messaging](https://developers.google.com/cloud-messaging/) 14 | 15 | Getting Started 16 | --------------- 17 | 18 | - Follow the [quickstart guide](https://developers.google.com/cloud-messaging/) 19 | to set up your project in Android Studio. 20 | - Run the sample on your Android device. 21 | - Update API_KEY in GcmSender.java, with API key from your project. 22 | - Run the terminal command to send GCM message to your device. 23 | - A notification containing the GCM message should be displayed on the 24 | device. 25 | 26 | NOTE 27 | ---- 28 | 29 | The GcmSender module in this project is emulating a server for the purposes of 30 | this sample, but it's not meant to serve as an example for a production app 31 | server. For information on GCM server implementaion 32 | see [About GCM Connection Server](https://developers.google.com/cloud-messaging/server) 33 | 34 | Screenshots 35 | ----------- 36 | ![Screenshot](app/src/main/gcm-sample.png) 37 | 38 | Support 39 | ------- 40 | 41 | - Stack Overflow: http://stackoverflow.com/questions/tagged/google-cloud-messaging 42 | 43 | If you've found an error in this sample, please file an issue: 44 | https://github.com/googlesamples/google-services/issues 45 | 46 | Patches are encouraged, and may be submitted by forking this project and 47 | submitting a pull request through GitHub. 48 | 49 | License 50 | ------- 51 | 52 | Copyright 2015 Google, Inc. 53 | 54 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 55 | license agreements. See the NOTICE file distributed with this work for 56 | additional information regarding copyright ownership. The ASF licenses this 57 | file to you under the Apache License, Version 2.0 (the "License"); you may not 58 | use this file except in compliance with the License. You may obtain a copy of 59 | the License at 60 | 61 | http://www.apache.org/licenses/LICENSE-2.0 62 | 63 | Unless required by applicable law or agreed to in writing, software 64 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 65 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 66 | License for the specific language governing permissions and limitations under 67 | the License. 68 | -------------------------------------------------------------------------------- /android/gcm/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | buildToolsVersion '27.0.2' 6 | 7 | defaultConfig { 8 | applicationId "gcm.play.android.samples.com.gcmquickstart" 9 | minSdkVersion 14 10 | targetSdkVersion 27 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | packagingOptions { 23 | exclude 'LICENSE.txt' 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation 'com.google.android.gms:play-services-gcm:15.0.1' 29 | 30 | implementation 'com.android.support:appcompat-v7:27.1.0' 31 | 32 | // Testing dependencies 33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2' 34 | androidTestImplementation 'com.android.support.test:runner:0.5' 35 | androidTestImplementation 'com.android.support:support-annotations:27.1.0' 36 | } 37 | 38 | apply plugin: 'com.google.gms.google-services' 39 | -------------------------------------------------------------------------------- /android/gcm/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/gcm/app/src/androidTest/java/gcm/play/android/samples/com/gcmquickstart/MainActivityEspressoTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package gcm.play.android.samples.com.gcmquickstart; 18 | 19 | import android.support.test.rule.ActivityTestRule; 20 | import android.support.test.runner.AndroidJUnit4; 21 | import android.test.suitebuilder.annotation.LargeTest; 22 | 23 | import org.junit.Rule; 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | 27 | import static android.support.test.espresso.Espresso.onView; 28 | import static android.support.test.espresso.assertion.ViewAssertions.matches; 29 | import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; 30 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 31 | 32 | @RunWith(AndroidJUnit4.class) 33 | @LargeTest 34 | public class MainActivityEspressoTest { 35 | 36 | @Rule 37 | public ActivityTestRule mActivityRule = 38 | new ActivityTestRule<>(MainActivity.class); 39 | 40 | @Test 41 | public void displayInformationText_sameActivity() { 42 | onView(withId(R.id.informationTextView)).check(matches(isDisplayed())); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/gcm-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/gcm-sample.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/MyGcmListenerService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package gcm.play.android.samples.com.gcmquickstart; 18 | 19 | import android.app.NotificationManager; 20 | import android.app.PendingIntent; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.media.RingtoneManager; 24 | import android.net.Uri; 25 | import android.os.Bundle; 26 | import android.support.v4.app.NotificationCompat; 27 | import android.util.Log; 28 | 29 | import com.google.android.gms.gcm.GcmListenerService; 30 | 31 | public class MyGcmListenerService extends GcmListenerService { 32 | 33 | private static final String TAG = "MyGcmListenerService"; 34 | 35 | /** 36 | * Called when message is received. 37 | * 38 | * @param from SenderID of the sender. 39 | * @param data Data bundle containing message data as key/value pairs. 40 | * For Set of keys use data.keySet(). 41 | */ 42 | // [START receive_message] 43 | @Override 44 | public void onMessageReceived(String from, Bundle data) { 45 | String message = data.getString("message"); 46 | Log.d(TAG, "From: " + from); 47 | Log.d(TAG, "Message: " + message); 48 | 49 | if (from.startsWith("/topics/")) { 50 | // message received from some topic. 51 | } else { 52 | // normal downstream message. 53 | } 54 | 55 | // [START_EXCLUDE] 56 | /** 57 | * Production applications would usually process the message here. 58 | * Eg: - Syncing with server. 59 | * - Store message in local database. 60 | * - Update UI. 61 | */ 62 | 63 | /** 64 | * In some cases it may be useful to show a notification indicating to the user 65 | * that a message was received. 66 | */ 67 | sendNotification(message); 68 | // [END_EXCLUDE] 69 | } 70 | // [END receive_message] 71 | 72 | /** 73 | * Create and show a simple notification containing the received GCM message. 74 | * 75 | * @param message GCM message received. 76 | */ 77 | private void sendNotification(String message) { 78 | Intent intent = new Intent(this, MainActivity.class); 79 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 80 | PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 81 | PendingIntent.FLAG_ONE_SHOT); 82 | 83 | Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 84 | NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 85 | .setSmallIcon(R.drawable.ic_stat_ic_notification) 86 | .setContentTitle("GCM Message") 87 | .setContentText(message) 88 | .setAutoCancel(true) 89 | .setSound(defaultSoundUri) 90 | .setContentIntent(pendingIntent); 91 | 92 | NotificationManager notificationManager = 93 | (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 94 | 95 | notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/MyInstanceIDListenerService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package gcm.play.android.samples.com.gcmquickstart; 18 | 19 | import android.content.Intent; 20 | import android.content.SharedPreferences; 21 | import android.preference.PreferenceManager; 22 | import android.util.Log; 23 | 24 | import com.google.android.gms.iid.InstanceID; 25 | import com.google.android.gms.iid.InstanceIDListenerService; 26 | 27 | public class MyInstanceIDListenerService extends InstanceIDListenerService { 28 | 29 | private static final String TAG = "MyInstanceIDLS"; 30 | 31 | /** 32 | * Called if InstanceID token is updated. This may occur if the security of 33 | * the previous token had been compromised. This call is initiated by the 34 | * InstanceID provider. 35 | */ 36 | // [START refresh_token] 37 | @Override 38 | public void onTokenRefresh() { 39 | // Fetch updated Instance ID token and notify our app's server of any changes (if applicable). 40 | Intent intent = new Intent(this, RegistrationIntentService.class); 41 | startService(intent); 42 | } 43 | // [END refresh_token] 44 | } 45 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/QuickstartPreferences.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package gcm.play.android.samples.com.gcmquickstart; 18 | 19 | public class QuickstartPreferences { 20 | 21 | public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer"; 22 | public static final String REGISTRATION_COMPLETE = "registrationComplete"; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-hdpi-v11/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-hdpi-v11/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-hdpi/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-hdpi/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-mdpi-v11/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-mdpi-v11/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-mdpi/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-mdpi/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-xhdpi-v11/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-xhdpi-v11/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-xhdpi/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-xhdpi/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-xxhdpi-v11/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-xxhdpi-v11/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/drawable-xxhdpi/ic_stat_ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/drawable-xxhdpi/ic_stat_ic_notification.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 14 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #607D8B 4 | #546E7A 5 | #455A64 6 | #37474F 7 | #263238 8 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GCM Quickstart 3 | Token retrieved and sent to server! You can now use gcmsender to 4 | send downstream messages to this app. 5 | Generating InstanceID token... 6 | An error occurred while either fetching the InstanceID token, 7 | sending the fetched token to the server or subscribing to the PubSub topic. Please try 8 | running the sample again. 9 | 10 | -------------------------------------------------------------------------------- /android/gcm/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/gcm/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | mavenLocal() 7 | maven { url 'https://maven.google.com' } 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | classpath 'com.google.gms:google-services:3.1.0' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | mavenLocal() 19 | maven { url 'https://maven.google.com' } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /android/gcm/gcmsender/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'application' 2 | 3 | mainClassName = "gcm.play.android.samples.com.gcmsender.GcmSender" 4 | 5 | run { 6 | def params = [] 7 | if (project.hasProperty('msg')) { 8 | params.add(project.msg) 9 | if (project.hasProperty('to')) { 10 | params.add(project.to) 11 | } 12 | } 13 | args params 14 | } 15 | 16 | dependencies { 17 | compile 'org.apache.commons:commons-io:1.3.2' 18 | compile 'org.json:json:20140107' 19 | } 20 | -------------------------------------------------------------------------------- /android/gcm/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /android/gcm/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gcm/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gcm/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip 6 | -------------------------------------------------------------------------------- /android/gcm/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/gcm/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':gcmsender' 2 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':analytics:app', ':gcm:app', ':signin:app' 2 | -------------------------------------------------------------------------------- /android/signin/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | local.properties 3 | .idea 4 | build/ 5 | .DS_Store 6 | *.iml 7 | *.apk 8 | *.aar 9 | *.zip 10 | google-services.json 11 | -------------------------------------------------------------------------------- /android/signin/.google/packaging.yml: -------------------------------------------------------------------------------- 1 | # GOOGLE SAMPLE PACKAGING DATA 2 | # 3 | # This file is used by Google as part of our samples packaging process. 4 | # End users may safely ignore this file. It has no relevance to other systems. 5 | --- 6 | # Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED} 7 | status: DRAFT 8 | 9 | # Optional, put additional explanation here for DEPRECATED or SUPERCEDED. 10 | # statusNote: 11 | # See http://go/sample-categories 12 | technologies: [Android, Google Play services, Google Sign-In, Google+] 13 | categories: [Getting Started] 14 | languages: [Java] 15 | solutions: [Mobile] 16 | 17 | # May be omitted if unpublished 18 | # github:ged 19 | 20 | # Values: BEGINNER | INTERMEDIATE | ADVANCED | EXPERT 21 | level: BEGINNER 22 | 23 | # Dimensions: 512x512, PNG fomrat 24 | icon: app/src/main/res/drawable/ic_launcher_big.png 25 | 26 | # Default: apache2. May be omitted for most samples. 27 | # Alternatives: apache2-android (for AOSP) 28 | license: apache2 29 | -------------------------------------------------------------------------------- /android/signin/README.md: -------------------------------------------------------------------------------- 1 | Google Sign-In Quickstart 2 | ========================= 3 | 4 | The Google Sign-In Android quickstart demonstrates how to authenticate a user with GoogleSignInClient. 5 | 6 | Introduction 7 | ------------ 8 | 9 | - [Read more about Google Sign-In](https://developers.google.com/identity/sign-in/) 10 | 11 | Getting Started 12 | --------------- 13 | 14 | - Follow the [quickstart guide](https://developers.google.com/identity/sign-in/android/start) to set up your project in Android Studio. 15 | - Run the sample on your Android device or emulator. 16 | - The running sample allows Google accounts on the device to sign-in. 17 | 18 | Screenshots 19 | ----------- 20 | ![Screenshot](app/src/main/sign-in-sample.png) 21 | 22 | Support 23 | ------- 24 | 25 | - Stack Overflow: http://stackoverflow.com/questions/tagged/google-identity 26 | 27 | If you've found an error in this sample, please file an issue: 28 | https://github.com/googlesamples/google-services/issues 29 | 30 | Patches are encouraged, and may be submitted by forking this project and 31 | submitting a pull request through GitHub. 32 | 33 | License 34 | ------- 35 | 36 | Copyright 2015 Google, Inc. 37 | 38 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 39 | license agreements. See the NOTICE file distributed with this work for 40 | additional information regarding copyright ownership. The ASF licenses this 41 | file to you under the Apache License, Version 2.0 (the "License"); you may not 42 | use this file except in compliance with the License. You may obtain a copy of 43 | the License at 44 | 45 | http://www.apache.org/licenses/LICENSE-2.0 46 | 47 | Unless required by applicable law or agreed to in writing, software 48 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 49 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 50 | License for the specific language governing permissions and limitations under 51 | the License. 52 | -------------------------------------------------------------------------------- /android/signin/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion '29.0.2' 6 | 7 | defaultConfig { 8 | applicationId "com.google.samples.quickstart.signin" 9 | minSdkVersion 18 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | packagingOptions { 25 | exclude 'LICENSE.txt' 26 | exclude 'META-INF/DEPENDENCIES' 27 | } 28 | 29 | // Resolve dependency differences between app and tests 30 | configurations.all { 31 | resolutionStrategy.force 'com.android.support:support-annotations:27.1.0' 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation 'androidx.appcompat:appcompat:1.1.0' 37 | implementation 'com.google.android.material:material:1.0.0' 38 | 39 | // Dependency for Google Sign-In 40 | implementation 'com.google.android.gms:play-services-auth:17.0.0' 41 | 42 | // Dependencies for the REST API example 43 | implementation 'com.google.api-client:google-api-client:1.30.5' 44 | implementation 'com.google.api-client:google-api-client-android:1.30.5' 45 | implementation 'com.google.apis:google-api-services-people:v1-rev99-1.22.0' 46 | 47 | // UiAutomatorTesting 48 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 49 | androidTestImplementation 'androidx.test:rules:1.2.0' 50 | androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' 51 | androidTestImplementation 'androidx.annotation:annotation:1.1.0' 52 | } 53 | -------------------------------------------------------------------------------- /android/signin/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/signin/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 30 | 31 | 35 | 36 | 37 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /android/signin/app/src/main/java/com/google/samples/quickstart/signin/ChooserActivity.java: -------------------------------------------------------------------------------- 1 | package com.google.samples.quickstart.signin; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import androidx.appcompat.app.AppCompatActivity; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.AdapterView; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.ListView; 13 | import android.widget.TextView; 14 | 15 | /** 16 | * Simple list-based Activity to redirect to one of the other Activities. The code here is 17 | * uninteresting, {@link SignInActivity} is a good place to start if you are curious about 18 | * {@code GoogleSignInApi}. 19 | */ 20 | public class ChooserActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { 21 | 22 | private static final Class[] CLASSES = new Class[]{ 23 | SignInActivity.class, 24 | SignInActivityWithDrive.class, 25 | IdTokenActivity.class, 26 | ServerAuthCodeActivity.class, 27 | RestApiActivity.class, 28 | }; 29 | 30 | private static final int[] DESCRIPTION_IDS = new int[] { 31 | R.string.desc_sign_in_activity, 32 | R.string.desc_sign_in_activity_scopes, 33 | R.string.desc_id_token_activity, 34 | R.string.desc_auth_code_activity, 35 | R.string.desc_rest_activity, 36 | }; 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_chooser); 42 | 43 | // Set up ListView and Adapter 44 | ListView listView = findViewById(R.id.list_view); 45 | 46 | MyArrayAdapter adapter = new MyArrayAdapter(this, android.R.layout.simple_list_item_2, CLASSES); 47 | adapter.setDescriptionIds(DESCRIPTION_IDS); 48 | 49 | listView.setAdapter(adapter); 50 | listView.setOnItemClickListener(this); 51 | } 52 | 53 | @Override 54 | public void onItemClick(AdapterView parent, View view, int position, long id) { 55 | Class clicked = CLASSES[position]; 56 | startActivity(new Intent(this, clicked)); 57 | } 58 | 59 | public static class MyArrayAdapter extends ArrayAdapter { 60 | 61 | private Context mContext; 62 | private Class[] mClasses; 63 | private int[] mDescriptionIds; 64 | 65 | public MyArrayAdapter(Context context, int resource, Class[] objects) { 66 | super(context, resource, objects); 67 | 68 | mContext = context; 69 | mClasses = objects; 70 | } 71 | 72 | @Override 73 | public View getView(int position, View convertView, ViewGroup parent) { 74 | View view = convertView; 75 | 76 | if (convertView == null) { 77 | LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); 78 | view = inflater.inflate(android.R.layout.simple_list_item_2, null); 79 | } 80 | 81 | ((TextView) view.findViewById(android.R.id.text1)).setText(mClasses[position].getSimpleName()); 82 | ((TextView) view.findViewById(android.R.id.text2)).setText(mDescriptionIds[position]); 83 | 84 | return view; 85 | } 86 | 87 | public void setDescriptionIds(int[] descriptionIds) { 88 | mDescriptionIds = descriptionIds; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/drawable-hdpi/googleg_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/drawable-hdpi/googleg_color.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/drawable-mdpi/googleg_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/drawable-mdpi/googleg_color.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/drawable-xhdpi/googleg_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/drawable-xhdpi/googleg_color.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/drawable-xxhdpi/googleg_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/drawable-xxhdpi/googleg_color.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/drawable/ic_launcher_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/drawable/ic_launcher_big.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/layout/activity_chooser.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/signin/app/src/main/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20dp 4 | 5 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #607D8B 4 | #546E7A 5 | #455A64 6 | #37474F 7 | #263238 8 | 9 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 100dp 7 | 8 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Sign-In Quickstart 3 | Google Sign-In\nQuickstart 4 | 5 | 6 | Signed in as: %s 7 | Signed in 8 | Signing in… 9 | Signed out 10 | "Error: please check logs." 11 | 12 | Error: Plus.PeopleApi.getCurrentPerson returned null. Ensure that the Google+ API is 13 | enabled for your project, you have a properly configured google-services.json file 14 | and that your device has an internet connection. 15 | 16 | Loading… 17 | Auth Code: %s 18 | ID Token: %s 19 | 20 | 21 | Google Play Services Error: %i 22 | 23 | 24 | Sign Out 25 | Disconnect 26 | Get Fresh Token 27 | 28 | 29 | Google Logo 30 | 31 | 32 | Contacts access is needed in order to retrieve your email address. 33 | 34 | 35 | SignInActivity 36 | Signing in, signing out, and revoking access. 37 | Signing in, signing out, and revoking access with Google Drive permissions. 38 | 39 | IdTokenActivity 40 | Retrieving an ID Token for the user. 41 | 42 | Demonstrate retrieving an auth code for authorizing your server. 43 | ServerAuthCodeActivity 44 | 45 | Demonstrate using Google Sign In with a Google REST API 46 | RestApiActivity 47 | 48 | 49 | Connections: %1$s 50 | Get contacts failed. 51 | 52 | 53 | 55 | YOUR_SERVER_CLIENT_ID 56 | 57 | -------------------------------------------------------------------------------- /android/signin/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 13 | 14 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /android/signin/app/src/main/sign-in-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/app/src/main/sign-in-sample.png -------------------------------------------------------------------------------- /android/signin/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | maven { url 'https://maven.google.com' } 7 | mavenLocal() 8 | google() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.5.1' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | maven { url 'https://maven.google.com' } 19 | mavenLocal() 20 | google() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /android/signin/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | android.enableJetifier=true 13 | android.useAndroidX=true 14 | org.gradle.jvmargs=-Xmx1536m 15 | 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | -------------------------------------------------------------------------------- /android/signin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/android/signin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/signin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Nov 02 00:02:54 GMT+01:00 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /android/signin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/signin/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample.xcodeproj/xcshareddata/xcschemes/AnalyticsExampleSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | 19 | @interface AppDelegate : UIResponder 20 | 21 | @property (strong, nonatomic) UIWindow *window; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import "AppDelegate.h" 18 | 19 | 20 | #import 21 | 22 | @implementation AppDelegate 23 | 24 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 25 | // [START tracker_objc] 26 | GAI *gai = [GAI sharedInstance]; 27 | [gai trackerWithTrackingId:@"YOUR_TRACKING_ID"]; 28 | 29 | // Optional: automatically report uncaught exceptions. 30 | gai.trackUncaughtExceptions = YES; 31 | 32 | // Optional: set Logger to VERBOSE for debug information. 33 | // Remove before app release. 34 | gai.logger.logLevel = kGAILogLevelVerbose; 35 | // [END tracker_objc] 36 | 37 | // Set a white background so that patterns are showcased. 38 | _window.backgroundColor = [UIColor whiteColor]; 39 | 40 | return YES; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/CircleImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | 19 | /** 20 | * CircleImageView is a UIImageView subclass that renders an image inside a 21 | * circle that has a drop shadow. It should be given equal width and height. 22 | * 23 | * This is shared between the Objective-C and Swift versions of the samples. 24 | */ 25 | IB_DESIGNABLE 26 | @interface CircleImageView : UIImageView 27 | @end 28 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/CircleImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import "CircleImageView.h" 18 | 19 | @implementation CircleImageView 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame { 22 | if ((self = [super initWithFrame:frame])) { 23 | [self sharedInit]; 24 | } 25 | return self; 26 | } 27 | 28 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 29 | if ((self = [super initWithCoder:aDecoder])) { 30 | [self sharedInit]; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)sharedInit { 36 | self.backgroundColor = [UIColor whiteColor]; 37 | super.contentMode = UIViewContentModeCenter; 38 | 39 | CALayer *layer = super.layer; 40 | layer.shadowOffset = CGSizeMake(0, 2); 41 | layer.shadowOpacity = 0.25; 42 | layer.shadowColor = [UIColor grayColor].CGColor; 43 | layer.shadowRadius = 4.0; 44 | layer.shadowOffset = CGSizeMake(0, 2); 45 | } 46 | 47 | - (void)layoutSubviews { 48 | [super layoutSubviews]; 49 | 50 | CGSize size = self.bounds.size; 51 | CGFloat dim = MAX(size.width, size.height); 52 | self.layer.cornerRadius = dim / 2; 53 | } 54 | 55 | - (void)setContentMode:(UIViewContentMode)contentMode { 56 | // ignore 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIcons 10 | 11 | CFBundleIcons~ipad 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0.1 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1 27 | LSRequiresIPhoneOS 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/PatternTabBarController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | 19 | /** 20 | * PatternTabBarController exists as a subclass of UITabBarConttroller that 21 | * supports a 'share' action. This will trigger a custom event to Analytics and 22 | * display a dialog. 23 | */ 24 | @interface PatternTabBarController : UITabBarController 25 | 26 | - (IBAction)didTapShare:(id)sender; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/PatternTabBarController.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import "PatternTabBarController.h" 18 | 19 | #import 20 | #import 21 | 22 | @implementation PatternTabBarController 23 | 24 | - (void)didTapShare:(id)sender { 25 | // [START custom_event_objc] 26 | id tracker = [GAI sharedInstance].defaultTracker; 27 | NSMutableDictionary *event = 28 | [[GAIDictionaryBuilder createEventWithCategory:@"Action" 29 | action:@"Share" 30 | label:nil 31 | value:nil] build]; 32 | [tracker send:event]; 33 | // [END custom_event_objc] 34 | 35 | NSString *title = [NSString stringWithFormat:@"Share: %@", 36 | self.selectedViewController.title]; 37 | NSString *message = 38 | @"Share event sent to Analytics; actual share not implemented in this quickstart"; 39 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title 40 | message:message 41 | delegate:nil 42 | cancelButtonTitle:@"Ok" 43 | otherButtonTitles:nil]; 44 | [alert show]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | 19 | @interface ViewController : UIViewController 20 | @end 21 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import "ViewController.h" 18 | 19 | // [START screen_view_hit_imports_objc] 20 | #import 21 | #import 22 | #import 23 | // [END screen_view_hit_imports_objc] 24 | 25 | @implementation ViewController 26 | 27 | - (void)viewWillAppear:(BOOL)animated { 28 | [super viewWillAppear:animated]; 29 | 30 | NSString *name = [NSString stringWithFormat:@"Pattern~%@", self.title]; 31 | 32 | // The UA-XXXXX-Y tracker ID is loaded automatically from the 33 | // GoogleService-Info.plist by the `GGLContext` in the AppDelegate. 34 | // If you're copying this to an app just using Analytics, you'll 35 | // need to configure your tracking ID here. 36 | // [START screen_view_hit_objc] 37 | id tracker = [GAI sharedInstance].defaultTracker; 38 | [tracker set:kGAIScreenName value:name]; 39 | [tracker send:[[GAIDictionaryBuilder createScreenView] build]]; 40 | // [END screen_view_hit_objc] 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import "AppDelegate.h" 19 | 20 | int main(int argc, char * argv[]) { 21 | @autoreleasepool { 22 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | @UIApplicationMain 20 | class AppDelegate: UIResponder, UIApplicationDelegate { 21 | 22 | var window: UIWindow? 23 | 24 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 25 | 26 | // [START tracker_swift] 27 | guard let gai = GAI.sharedInstance() else { 28 | assert(false, "Google Analytics not configured correctly") 29 | } 30 | gai.tracker(withTrackingId: "YOUR_TRACKING_ID") 31 | // Optional: automatically report uncaught exceptions. 32 | gai.trackUncaughtExceptions = true 33 | 34 | // Optional: set Logger to VERBOSE for debug information. 35 | // Remove before app release. 36 | gai.logger.logLevel = .verbose; 37 | // [END tracker_swift] 38 | 39 | // Set a white background so that patterns are showcased. 40 | window?.backgroundColor = UIColor.white 41 | 42 | return true 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleSwift/BridgingHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // Use this file to import your target's public headers that you would like to expose to Swift. 17 | // 18 | 19 | // [START screen_view_hit_imports_swift] 20 | #import 21 | #import 22 | #import 23 | // [END screen_view_hit_imports_swift] 24 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleSwift/PatternTabBarController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import Foundation 18 | 19 | /** 20 | * PatternTabBarController exists as a subclass of UITabBarConttroller that 21 | * supports a 'share' action. This will trigger a custom event to Analytics and 22 | * display a dialog. 23 | */ 24 | @objc(PatternTabBarController) // match the ObjC symbol name inside Storyboard 25 | class PatternTabBarController: UITabBarController { 26 | 27 | @IBAction func didTapShare(_ sender: AnyObject) { 28 | // [START custom_event_swift] 29 | guard let tracker = GAI.sharedInstance().defaultTracker else { return } 30 | guard let event = GAIDictionaryBuilder.createEvent(withCategory: "Action", action: "Share", label: nil, value: nil) else { return } 31 | tracker.send(event.build() as [NSObject : AnyObject]) 32 | // [END custom_event_swift] 33 | 34 | let title = "Share: \(self.selectedViewController!.title!)" 35 | let message = "Share event sent to Analytics; actual share not implemented in this quickstart" 36 | let alert = UIAlertView(title: title, message: message, delegate: nil, cancelButtonTitle: "Ok") 37 | alert.show() 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleSwift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | @objc(ViewController) // match the ObjC symbol name inside Storyboard 20 | class ViewController: UIViewController { 21 | 22 | override func viewWillAppear(_ animated: Bool) { 23 | super.viewWillAppear(true) 24 | 25 | let name = "Pattern~\(self.title!)" 26 | 27 | // The UA-XXXXX-Y tracker ID is loaded automatically from the 28 | // GoogleService-Info.plist by the `GGLContext` in the AppDelegate. 29 | // If you're copying this to an app just using Analytics, you'll 30 | // need to configure your tracking ID here. 31 | // [START screen_view_hit_swift] 32 | guard let tracker = GAI.sharedInstance().defaultTracker else { return } 33 | tracker.set(kGAIScreenName, value: name) 34 | 35 | guard let builder = GAIDictionaryBuilder.createScreenView() else { return } 36 | tracker.send(builder.build() as [NSObject : AnyObject]) 37 | // [END screen_view_hit_swift] 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleTests/AppTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import 19 | 20 | #import 21 | 22 | #import "LogWrapper.h" 23 | 24 | static NSString * const kSearchTerm = @": Sending hit(s) "; 25 | 26 | @interface AppTests : XCTestCase 27 | @end 28 | 29 | @implementation AppTests { 30 | LogWrapper *_logWrapper; 31 | UITabBarController *_patternsController; 32 | GAI *_gai; 33 | GAILogLevel _previousLogLevel; 34 | } 35 | 36 | - (instancetype)init { 37 | if ((self = [super init])) { 38 | _gai = [GAI sharedInstance]; 39 | } 40 | return self; 41 | } 42 | 43 | - (void)setUp { 44 | _logWrapper = [[LogWrapper alloc] init]; 45 | _previousLogLevel = _gai.logger.logLevel; 46 | _gai.logger.logLevel = kGAILogLevelVerbose; // force verbose logging for test 47 | 48 | UIWindow *window = [UIApplication sharedApplication].keyWindow; 49 | UIViewController *rootViewController = window.rootViewController; 50 | for (UIViewController *candidate in rootViewController.childViewControllers) { 51 | if ([candidate isKindOfClass:[UITabBarController class]]) { 52 | _patternsController = (UITabBarController *)candidate; 53 | break; 54 | } 55 | } 56 | } 57 | 58 | - (void)tearDown { 59 | _logWrapper = nil; 60 | _gai.logger.logLevel = _previousLogLevel; 61 | } 62 | 63 | - (void)testLogs { 64 | XCTestExpectation *expectation = 65 | [self expectationWithDescription:@"Send event inside logs"]; 66 | [_logWrapper lines]; // force clear 67 | 68 | // Trigger a new, different tab to be shown. 69 | XCTAssertEqual(_patternsController.selectedIndex, 0, 70 | @"Expected left-most index to be initially selected"); 71 | _patternsController.selectedIndex = 2; 72 | 73 | // Check the logs constantly until a send message is found. 74 | NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.1 75 | target:self 76 | selector:@selector(checkTimer:) 77 | userInfo:expectation 78 | repeats:YES]; 79 | [self waitForExpectationsWithTimeout:10.0 handler:nil]; 80 | [timer invalidate]; 81 | } 82 | 83 | - (void)checkTimer:(NSTimer *)timer { 84 | XCTestExpectation *expectation = timer.userInfo; 85 | NSArray *lines = [_logWrapper lines]; 86 | 87 | for (NSString *line in lines) { 88 | if ([line containsString:kSearchTerm]) { 89 | [expectation fulfill]; 90 | break; 91 | } 92 | } 93 | 94 | } 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleTests/LogWrapper.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | 19 | /** 20 | * LogWrapper replaces the current stderr, matched to its lifetime. Any lines written to stderr 21 | * during this time can be retrieved by the -lines method. 22 | */ 23 | @interface LogWrapper : NSObject 24 | 25 | /** 26 | * Returns any lines (as NSString instances) written since LogWrapper was created, or the last 27 | * call to this method. This may return a nil/empty array if nothing was written. 28 | */ 29 | @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSArray *lines; 30 | 31 | @end 32 | 33 | -------------------------------------------------------------------------------- /ios/analytics/AnalyticsExampleTests/LogWrapper.mm: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import "LogWrapper.h" 18 | 19 | #include 20 | #include 21 | 22 | #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) 23 | 24 | @implementation LogWrapper { 25 | char _tempLogFile[64]; 26 | NSFileHandle *_handle; 27 | int _dupFd; 28 | } 29 | 30 | - (instancetype)init { 31 | if ((self = [super init])) { 32 | _dupFd = dup(fileno(stderr)); 33 | 34 | snprintf(_tempLogFile, ARRAYSIZE(_tempLogFile), "/tmp/objc-logwrapper.XXXXXX"); 35 | int fd = mkstemp(_tempLogFile); 36 | 37 | NSLog(@"LogWrapper writing to: %s", _tempLogFile); 38 | 39 | freopen(_tempLogFile, "w+", stderr); 40 | _handle = [[NSFileHandle alloc] initWithFileDescriptor:fd closeOnDealloc:YES]; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)dealloc { 46 | unlink(_tempLogFile); 47 | NSLog(@"~LogWrapper removed: %s", _tempLogFile); 48 | 49 | dup2(_dupFd, fileno(stderr)); 50 | close(_dupFd); 51 | } 52 | 53 | - (NSArray *)lines { 54 | NSData *data = [_handle readDataToEndOfFile]; 55 | [_handle seekToFileOffset:data.length]; 56 | 57 | if (data == nil || !data.bytes) { 58 | return nil; 59 | } 60 | 61 | NSString *allData = @((const char *)data.bytes); 62 | return [allData componentsSeparatedByString:@"\n"]; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "favorite.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "favorite_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "favorite_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/favorite.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/favorite_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/favorite_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/favorite_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/favorite.imageset/favorite_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "flash_on.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "flash_on_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "flash_on_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/flash_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/flash_on.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/flash_on_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/flash_on_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/flash_on_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/flash_on.imageset/flash_on_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icon-favorite.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "icon-favorite_2x-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "icon-favorite_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/icon-favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/icon-favorite.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/icon-favorite_2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/icon-favorite_2x-1.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/icon-favorite_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-favorite.imageset/icon-favorite_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icon-flash_on.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "icon-flash_on_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "icon-flash_on_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/icon-flash_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/icon-flash_on.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/icon-flash_on_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/icon-flash_on_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/icon-flash_on_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-flash_on.imageset/icon-flash_on_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icon-tag_faces.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "icon-tag_faces_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "icon-tag_faces_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/icon-tag_faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/icon-tag_faces.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/icon-tag_faces_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/icon-tag_faces_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/icon-tag_faces_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-tag_faces.imageset/icon-tag_faces_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icon-wb_incandescent.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "icon-wb_incandescent_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "icon-wb_incandescent_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/icon-wb_incandescent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/icon-wb_incandescent.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/icon-wb_incandescent_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/icon-wb_incandescent_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/icon-wb_incandescent_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/icon-wb_incandescent.imageset/icon-wb_incandescent_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "tag_faces.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "tag_faces_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "tag_faces_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/tag_faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/tag_faces.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/tag_faces_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/tag_faces_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/tag_faces_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/tag_faces.imageset/tag_faces_3x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "wb_incandescent.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "wb_incandescent_2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "wb_incandescent_3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/wb_incandescent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/wb_incandescent.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/wb_incandescent_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/wb_incandescent_2x.png -------------------------------------------------------------------------------- /ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/wb_incandescent_3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Images/AnalyticsImages.xcassets/wb_incandescent.imageset/wb_incandescent_3x.png -------------------------------------------------------------------------------- /ios/analytics/Podfile: -------------------------------------------------------------------------------- 1 | # AnalyticsExample 2 | 3 | use_frameworks! 4 | platform :ios, '7.0' 5 | pod 'GoogleAnalytics' 6 | 7 | target 'AnalyticsExample' do 8 | end 9 | target 'AnalyticsExampleSwift' do 10 | end 11 | target 'AnalyticsExampleTests' do 12 | end 13 | -------------------------------------------------------------------------------- /ios/analytics/README.md: -------------------------------------------------------------------------------- 1 | Google Analytics Quickstart 2 | =========================== 3 | 4 | Google Analytics iOS Quickstart app demonstrates collecting 5 | app usage analytics via the defaultTracker available from GAI. 6 | GAIDictionaryBuilder is used to build tracked events. 7 | 8 | Introduction 9 | ------------ 10 | 11 | - [Read more about Google Analytics](https://developers.google.com/analytics/) 12 | 13 | Getting Started 14 | --------------- 15 | 16 | - Follow the [quickstart guide](https://developers.google.com/analytics/devguides/collection/mobile/) 17 | to set up your project in XCode. 18 | - Run the sample on your iOS device or emulator. 19 | - Swipe between images to register screen views. 20 | - View collected analytics via [Google Analytics](https://www.google.com/analytics/web). 21 | 22 | Note: You will need Swift 3.0 to run the Swift version of this quickstart. 23 | 24 | Screenshots 25 | ----------- 26 | ![Screenshot](Screenshot/analytics-sample.png) 27 | 28 | Support 29 | ------- 30 | 31 | - Stack Overflow: http://stackoverflow.com/questions/tagged/google-analytics 32 | 33 | If you've found an error in this sample, please file an issue: 34 | https://github.com/googlesamples/google-services/issues 35 | 36 | Patches are encouraged, and may be submitted by forking this project and 37 | submitting a pull request through GitHub. 38 | 39 | License 40 | ------- 41 | 42 | Copyright 2015 Google, Inc. 43 | 44 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 45 | license agreements. See the NOTICE file distributed with this work for 46 | additional information regarding copyright ownership. The ASF licenses this 47 | file to you under the Apache License, Version 2.0 (the "License"); you may not 48 | use this file except in compliance with the License. You may obtain a copy of 49 | the License at 50 | 51 | http://www.apache.org/licenses/LICENSE-2.0 52 | 53 | Unless required by applicable law or agreed to in writing, software 54 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 55 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 56 | License for the specific language governing permissions and limitations under 57 | the License. 58 | -------------------------------------------------------------------------------- /ios/analytics/Screenshot/analytics-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/analytics/Screenshot/analytics-sample.png -------------------------------------------------------------------------------- /ios/gcm/GcmExample.xcodeproj/xcshareddata/xcschemes/GcmExampleSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/gcm/GcmExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import 19 | 20 | @interface AppDelegate : UIResponder 21 | 22 | @property(nonatomic, strong) UIWindow *window; 23 | @property(nonatomic, readonly, strong) NSString *registrationKey; 24 | @property(nonatomic, readonly, strong) NSString *messageKey; 25 | @property(nonatomic, readonly, strong) NSString *gcmSenderID; 26 | @property(nonatomic, readonly, strong) NSDictionary *registrationOptions; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /ios/gcm/GcmExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIcons 10 | 11 | CFBundleIcons~ipad 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0.1 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1 27 | LSRequiresIPhoneOS 28 | 29 | UIBackgroundModes 30 | 31 | remote-notification 32 | 33 | UILaunchStoryboardName 34 | LaunchScreen 35 | UIMainStoryboardFile 36 | Main 37 | UIRequiredDeviceCapabilities 38 | 39 | armv7 40 | 41 | UISupportedInterfaceOrientations 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | UISupportedInterfaceOrientations~ipad 48 | 49 | UIInterfaceOrientationPortrait 50 | UIInterfaceOrientationPortraitUpsideDown 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /ios/gcm/GcmExample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | 19 | @interface ViewController : UIViewController 20 | @property(nonatomic, weak) IBOutlet UILabel *registeringLabel; 21 | @property(nonatomic, weak) IBOutlet UIActivityIndicatorView *registrationProgressing; 22 | @end 23 | -------------------------------------------------------------------------------- /ios/gcm/GcmExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import "AppDelegate.h" 19 | 20 | int main(int argc, char * argv[]) { 21 | @autoreleasepool { 22 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/gcm/GcmExampleSwift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | @objc(ViewController) // match the ObjC symbol name inside Storyboard 20 | class ViewController: UIViewController { 21 | 22 | @IBOutlet weak var registeringLabel: UILabel! 23 | @IBOutlet weak var registrationProgressing: UIActivityIndicatorView! 24 | 25 | override func viewDidLoad() { 26 | super.viewDidLoad() 27 | guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } 28 | NotificationCenter.default.addObserver(self, 29 | selector: #selector(ViewController.updateRegistrationStatus(_:)), 30 | name: NSNotification.Name(rawValue: appDelegate.registrationKey), object: nil) 31 | NotificationCenter.default.addObserver(self, 32 | selector: #selector(ViewController.showReceivedMessage(_:)), 33 | name: NSNotification.Name(rawValue: appDelegate.messageKey), object: nil) 34 | registrationProgressing.hidesWhenStopped = true 35 | registrationProgressing.startAnimating() 36 | } 37 | 38 | func updateRegistrationStatus(_ notification: Notification) { 39 | registrationProgressing.stopAnimating() 40 | if let info = notification.userInfo as? [String:String] { 41 | if let error = info["error"] { 42 | registeringLabel.text = "Error registering!" 43 | showAlert("Error registering with GCM", message: error) 44 | } else if let _ = info["registrationToken"] { 45 | registeringLabel.text = "Registered!" 46 | let message = "Check the xcode debug console for the registration token that you " + 47 | " can use with the demo server to send notifications to your device" 48 | showAlert("Registration Successful!", message: message) 49 | } 50 | } else { 51 | print("Software failure. Guru meditation.") 52 | } 53 | } 54 | 55 | func showReceivedMessage(_ notification: Notification) { 56 | if let info = notification.userInfo as? [String:AnyObject] { 57 | if let aps = info["aps"] as? [String:String] { 58 | showAlert("Message received", message: aps["alert"]!) 59 | } 60 | } else { 61 | print("Software failure. Guru meditation.") 62 | } 63 | } 64 | 65 | func showAlert(_ title: String, message: String) { 66 | if #available(iOS 8.0, *) { 67 | let alert = UIAlertController(title: title, 68 | message: message, preferredStyle: .alert) 69 | let dismissAction = UIAlertAction(title: "Dismiss", style: .destructive, handler: nil) 70 | alert.addAction(dismissAction) 71 | self.present(alert, animated: true, completion: nil) 72 | } else { 73 | // Fallback on earlier versions 74 | let alert = UIAlertView.init(title: title, message: message, delegate: nil, 75 | cancelButtonTitle: "Dismiss") 76 | alert.show() 77 | } 78 | } 79 | 80 | override var preferredStatusBarStyle: UIStatusBarStyle { 81 | return UIStatusBarStyle.lightContent 82 | } 83 | 84 | deinit { 85 | NotificationCenter.default.removeObserver(self) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /ios/gcm/GcmExampleTests/GcmExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // GcmExampleTests.m 3 | // GcmExampleTests 4 | // 5 | // Created by Ibrahim Ulukaya on 12/15/16. 6 | // Copyright © 2016 Google Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GcmExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation GcmExampleTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/gcm/GcmExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/gcm/GcmServerDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015 Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import Cocoa 18 | 19 | @NSApplicationMain 20 | class AppDelegate: NSObject, NSApplicationDelegate { 21 | 22 | @IBOutlet weak var window: NSWindow! 23 | 24 | var masterViewController: MasterViewController! 25 | 26 | func applicationDidFinishLaunching(aNotification: NSNotification) { 27 | masterViewController = MasterViewController(nibName: "MasterViewController", bundle: nil) 28 | window.contentView!.addSubview(masterViewController.view) 29 | masterViewController.view.frame = (window.contentView! as NSView).bounds 30 | } 31 | 32 | func applicationWillTerminate(aNotification: NSNotification) { 33 | // Insert code here to tear down your application 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ios/gcm/GcmServerDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /ios/gcm/GcmServerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2015 Google Inc. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /ios/gcm/Podfile: -------------------------------------------------------------------------------- 1 | # GcmExample 2 | use_frameworks! 3 | platform :ios, '7.0' 4 | pod 'Google/CloudMessaging' 5 | 6 | target 'GcmExample' do 7 | end 8 | target 'GcmExampleSwift' do 9 | end 10 | -------------------------------------------------------------------------------- /ios/gcm/README.md: -------------------------------------------------------------------------------- 1 | Google Cloud Messaging Quickstart 2 | ================================= 3 | 4 | The Google Cloud Messaging iOS Quickstart app demonstrates how to connect 5 | an iOS app to GCM and how to receive messages. 6 | 7 | Introduction 8 | ------------ 9 | 10 | - [Read more about Google Cloud Messaging](https://developers.google.com/cloud-messaging/). 11 | 12 | Getting Started 13 | --------------- 14 | 15 | - Follow the [quickstart guide](https://developers.google.com/cloud-messaging/ios/start) 16 | to set up your project in XCode. 17 | - Run the sample on your iOS device. 18 | - Run the included GcmServerDemo. 19 | - Insert the API key from your project in the *apiKey* text field of the GcmServerDemo app. 20 | - Insert the registration token that the sample app has printed in the XCode debug console in the 21 | *RegistrationToken* text field of the GcmServerDemo app. 22 | - Click the *Send notification* button. A notification will be sent to your device. 23 | 24 | Note: You need Swift 2.0 to run the Swift version of this quickstart. 25 | 26 | Screenshots 27 | ----------- 28 | ![Screenshot](Screenshot/gcm-sample.png) 29 | 30 | Support 31 | ------- 32 | 33 | - Stack Overflow: http://stackoverflow.com/questions/tagged/google-cloud-messaging 34 | 35 | If you've found an error in this sample, please file an issue: 36 | https://github.com/googlesamples/google-services/issues 37 | 38 | Patches are encouraged, and may be submitted by forking this project and 39 | submitting a pull request through GitHub. 40 | 41 | License 42 | ------- 43 | 44 | Copyright 2015 Google, Inc. 45 | 46 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 47 | license agreements. See the NOTICE file distributed with this work for 48 | additional information regarding copyright ownership. The ASF licenses this 49 | file to you under the Apache License, Version 2.0 (the "License"); you may not 50 | use this file except in compliance with the License. You may obtain a copy of 51 | the License at 52 | 53 | http://www.apache.org/licenses/LICENSE-2.0 54 | 55 | Unless required by applicable law or agreed to in writing, software 56 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 57 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 58 | License for the specific language governing permissions and limitations under 59 | the License. 60 | -------------------------------------------------------------------------------- /ios/gcm/Screenshot/gcm-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/gcm/Screenshot/gcm-sample.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-60-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-60-2x.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-60-3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-60-3x.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-76-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-76-2x.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/AppIcon.appiconset/AppIcon-76.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon-60-2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "AppIcon-60-3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "idiom" : "ipad", 47 | "size" : "20x20", 48 | "scale" : "1x" 49 | }, 50 | { 51 | "idiom" : "ipad", 52 | "size" : "20x20", 53 | "scale" : "2x" 54 | }, 55 | { 56 | "idiom" : "ipad", 57 | "size" : "29x29", 58 | "scale" : "1x" 59 | }, 60 | { 61 | "idiom" : "ipad", 62 | "size" : "29x29", 63 | "scale" : "2x" 64 | }, 65 | { 66 | "idiom" : "ipad", 67 | "size" : "40x40", 68 | "scale" : "1x" 69 | }, 70 | { 71 | "idiom" : "ipad", 72 | "size" : "40x40", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "76x76", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon-76.png", 79 | "scale" : "1x" 80 | }, 81 | { 82 | "size" : "76x76", 83 | "idiom" : "ipad", 84 | "filename" : "AppIcon-76-2x.png", 85 | "scale" : "2x" 86 | }, 87 | { 88 | "idiom" : "ipad", 89 | "size" : "83.5x83.5", 90 | "scale" : "2x" 91 | } 92 | ], 93 | "info" : { 94 | "version" : 1, 95 | "author" : "xcode" 96 | } 97 | } -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "Icon.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Icon.imageset/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/Icon.imageset/Icon.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "scale" : "3x" 10 | }, 11 | { 12 | "orientation" : "landscape", 13 | "idiom" : "iphone", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "8.0", 16 | "subtype" : "736h", 17 | "scale" : "3x" 18 | }, 19 | { 20 | "orientation" : "portrait", 21 | "idiom" : "iphone", 22 | "extent" : "full-screen", 23 | "minimum-system-version" : "8.0", 24 | "subtype" : "667h", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "orientation" : "portrait", 29 | "idiom" : "iphone", 30 | "extent" : "full-screen", 31 | "minimum-system-version" : "7.0", 32 | "filename" : "Default_2x.png", 33 | "scale" : "2x" 34 | }, 35 | { 36 | "extent" : "full-screen", 37 | "idiom" : "iphone", 38 | "subtype" : "retina4", 39 | "filename" : "Default-568h_2x.png", 40 | "minimum-system-version" : "7.0", 41 | "orientation" : "portrait", 42 | "scale" : "2x" 43 | }, 44 | { 45 | "orientation" : "portrait", 46 | "idiom" : "ipad", 47 | "extent" : "full-screen", 48 | "minimum-system-version" : "7.0", 49 | "filename" : "Default-Portrait~ipad.png", 50 | "scale" : "1x" 51 | }, 52 | { 53 | "orientation" : "landscape", 54 | "idiom" : "ipad", 55 | "extent" : "full-screen", 56 | "minimum-system-version" : "7.0", 57 | "filename" : "Default-Landscape~ipad.png", 58 | "scale" : "1x" 59 | }, 60 | { 61 | "orientation" : "portrait", 62 | "idiom" : "ipad", 63 | "extent" : "full-screen", 64 | "minimum-system-version" : "7.0", 65 | "filename" : "Default-Portrait_2x~ipad.png", 66 | "scale" : "2x" 67 | }, 68 | { 69 | "orientation" : "landscape", 70 | "idiom" : "ipad", 71 | "extent" : "full-screen", 72 | "minimum-system-version" : "7.0", 73 | "filename" : "Default-Landscape_2x~ipad.png", 74 | "scale" : "2x" 75 | } 76 | ], 77 | "info" : { 78 | "version" : 1, 79 | "author" : "xcode" 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Default-568h_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/LaunchImage.launchimage/Default-568h_2x.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Landscape_2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Landscape_2x~ipad.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Portrait_2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Portrait_2x~ipad.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/LaunchImage.launchimage/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/LaunchImage.launchimage/Default_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/LaunchImage.launchimage/Default_2x.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Logo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "FriendlyPing-Logo.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | }, 16 | { 17 | "idiom" : "iphone", 18 | "scale" : "1x" 19 | }, 20 | { 21 | "idiom" : "iphone", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "idiom" : "iphone", 26 | "scale" : "3x" 27 | } 28 | ], 29 | "info" : { 30 | "version" : 1, 31 | "author" : "xcode" 32 | } 33 | } -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Logo.imageset/FriendlyPing-Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/Logo.imageset/FriendlyPing-Logo.png -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Watermark.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "FriendlyPing-Watermark.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ios/shared/Images.xcassets/Watermark.imageset/FriendlyPing-Watermark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/shared/Images.xcassets/Watermark.imageset/FriendlyPing-Watermark.png -------------------------------------------------------------------------------- /ios/shared/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ios/signin/.gitignore: -------------------------------------------------------------------------------- 1 | GoogleService-Info.plist 2 | *.xcworkspace 3 | Podfile.lock 4 | -------------------------------------------------------------------------------- /ios/signin/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/signin/Default-568h@2x.png -------------------------------------------------------------------------------- /ios/signin/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | platform :ios, '8.0' 3 | pod 'GoogleSignIn' 4 | 5 | target 'SignInExample' do 6 | end 7 | target 'SignInExampleSwift' do 8 | end 9 | -------------------------------------------------------------------------------- /ios/signin/README.md: -------------------------------------------------------------------------------- 1 | Google Sign-In Quickstart 2 | ========================= 3 | 4 | The Google Sign-In iOS quickstart demonstrates how to authenticate a user with GPPSignIn. 5 | 6 | Introduction 7 | ------------ 8 | 9 | - [Read more about Google Sign-In](https://developers.google.com/identity/sign-in/) 10 | 11 | Getting Started 12 | --------------- 13 | 14 | - Follow the [quickstart guide](https://developers.google.com/identity/sign-in/ios/start) to set up your project. 15 | - Run the sample on your iOS device or emulator. 16 | - The running sample allows users to sign-in with Google accounts. 17 | 18 | Screenshots 19 | ----------- 20 | ![Screenshot](Screenshot/sign-in-sample.png) 21 | 22 | Support 23 | ------- 24 | 25 | - Stack Overflow: http://stackoverflow.com/questions/tagged/google-oauth 26 | 27 | If you've found an error in this sample, please file an issue: 28 | https://github.com/googlesamples/google-services/issues 29 | 30 | Patches are encouraged, and may be submitted by forking this project and 31 | submitting a pull request through GitHub. 32 | 33 | License 34 | ------- 35 | 36 | Copyright 2015 Google, Inc. 37 | 38 | Licensed to the Apache Software Foundation (ASF) under one or more contributor 39 | license agreements. See the NOTICE file distributed with this work for 40 | additional information regarding copyright ownership. The ASF licenses this 41 | file to you under the Apache License, Version 2.0 (the "License"); you may not 42 | use this file except in compliance with the License. You may obtain a copy of 43 | the License at 44 | 45 | http://www.apache.org/licenses/LICENSE-2.0 46 | 47 | Unless required by applicable law or agreed to in writing, software 48 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 49 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 50 | License for the specific language governing permissions and limitations under 51 | the License. 52 | -------------------------------------------------------------------------------- /ios/signin/Screenshot/sign-in-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/signin/Screenshot/sign-in-sample.png -------------------------------------------------------------------------------- /ios/signin/SignInExample.xcodeproj/xcshareddata/xcschemes/SignInExampleSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | // [START signin_import] 19 | @import GoogleSignIn; 20 | // [END signin_import] 21 | 22 | // [START appdelegate_interfaces] 23 | @interface AppDelegate : UIResponder 24 | // [END appdelegate_interfaces] 25 | 26 | @property (strong, nonatomic) UIWindow *window; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import "AppDelegate.h" 18 | 19 | @implementation AppDelegate 20 | 21 | // [START didfinishlaunching] 22 | - (BOOL)application:(UIApplication *)application 23 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 24 | 25 | [GIDSignIn sharedInstance].clientID = @"YOUR_CLIENT_ID"; 26 | [GIDSignIn sharedInstance].delegate = self; 27 | 28 | return YES; 29 | } 30 | // [END didfinishlaunching] 31 | 32 | // [START openurl_new] 33 | - (BOOL)application:(UIApplication *)app 34 | openURL:(NSURL *)url 35 | options:(NSDictionary *)options { 36 | return [[GIDSignIn sharedInstance] handleURL:url]; 37 | } 38 | // [END openurl_new] 39 | 40 | // [START openurl] 41 | - (BOOL)application:(UIApplication *)application 42 | openURL:(NSURL *)url 43 | sourceApplication:(NSString *)sourceApplication 44 | annotation:(id)annotation { 45 | return [[GIDSignIn sharedInstance] handleURL:url]; 46 | } 47 | // [END openurl] 48 | 49 | // [START signin_handler] 50 | - (void)signIn:(GIDSignIn *)signIn 51 | didSignInForUser:(GIDGoogleUser *)user 52 | withError:(NSError *)error { 53 | if (error != nil) { 54 | if (error.code == kGIDSignInErrorCodeHasNoAuthInKeychain) { 55 | NSLog(@"The user has not signed in before or they have since signed out."); 56 | } else { 57 | NSLog(@"%@", error.localizedDescription); 58 | } 59 | // [START_EXCLUDE silent] 60 | [[NSNotificationCenter defaultCenter] 61 | postNotificationName:@"ToggleAuthUINotification" 62 | object:nil 63 | userInfo:nil]; 64 | // [END_EXCLUDE] 65 | return; 66 | } 67 | // Perform any operations on signed in user here. 68 | NSString *userId = user.userID; // For client-side use only! 69 | NSString *idToken = user.authentication.idToken; // Safe to send to the server 70 | NSString *fullName = user.profile.name; 71 | NSString *givenName = user.profile.givenName; 72 | NSString *familyName = user.profile.familyName; 73 | NSString *email = user.profile.email; 74 | // [START_EXCLUDE] 75 | NSDictionary *statusText = @{@"statusText": 76 | [NSString stringWithFormat:@"Signed in user: %@", 77 | fullName]}; 78 | [[NSNotificationCenter defaultCenter] 79 | postNotificationName:@"ToggleAuthUINotification" 80 | object:nil 81 | userInfo:statusText]; 82 | // [END_EXCLUDE] 83 | } 84 | // [END signin_handler] 85 | 86 | // This callback is triggered after the disconnect call that revokes data 87 | // access to the user's resources has completed. 88 | // [START disconnect_handler] 89 | - (void)signIn:(GIDSignIn *)signIn 90 | didDisconnectWithUser:(GIDGoogleUser *)user 91 | withError:(NSError *)error { 92 | // Perform any operations when the user disconnects from app here. 93 | // [START_EXCLUDE] 94 | NSDictionary *statusText = @{@"statusText": @"Disconnected user" }; 95 | [[NSNotificationCenter defaultCenter] 96 | postNotificationName:@"ToggleAuthUINotification" 97 | object:nil 98 | userInfo:statusText]; 99 | // [END_EXCLUDE] 100 | } 101 | // [END disconnect_handler] 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleURLTypes 22 | 23 | 24 | CFBundleTypeRole 25 | Editor 26 | CFBundleURLName 27 | google 28 | CFBundleURLSchemes 29 | 30 | YOUR_REVERSED_CLIENT_ID 31 | 32 | 33 | 34 | CFBundleVersion 35 | 1 36 | LSRequiresIPhoneOS 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIMainStoryboardFile 41 | Main 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | @import GoogleSignIn; 19 | 20 | // [START viewcontroller_interfaces] 21 | @interface ViewController : UIViewController 22 | // [END viewcontroller_interfaces] 23 | 24 | // [START viewcontroller_vars] 25 | @property (weak, nonatomic) IBOutlet GIDSignInButton *signInButton; 26 | @property (weak, nonatomic) IBOutlet UIButton *signOutButton; 27 | @property (weak, nonatomic) IBOutlet UIButton *disconnectButton; 28 | @property (weak, nonatomic) IBOutlet UILabel *statusText; 29 | // [END viewcontroller_vars] 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | #import "ViewController.h" 17 | 18 | @implementation ViewController 19 | 20 | // [START viewdidload] 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | [GIDSignIn sharedInstance].presentingViewController = self; 25 | 26 | // Automatically sign in the user. 27 | [[GIDSignIn sharedInstance] restorePreviousSignIn]; 28 | 29 | // [START_EXCLUDE silent] 30 | [[NSNotificationCenter defaultCenter] 31 | addObserver:self 32 | selector:@selector(receiveToggleAuthUINotification:) 33 | name:@"ToggleAuthUINotification" 34 | object:nil]; 35 | 36 | [self toggleAuthUI]; 37 | self.statusText.text = @"Google Sign in\niOS Demo"; 38 | // [END_EXCLUDE] 39 | } 40 | // [END viewdidload] 41 | 42 | // Signs the user out of the application for scenarios such as switching 43 | // profiles. 44 | // [START signout_tapped] 45 | - (IBAction)didTapSignOut:(id)sender { 46 | [[GIDSignIn sharedInstance] signOut]; 47 | // [START_EXCLUDE silent] 48 | [self toggleAuthUI]; 49 | // [END_EXCLUDE] 50 | } 51 | // [END signout_tapped] 52 | 53 | // Note: Disconnect revokes access to user data and should only be called in 54 | // scenarios such as when the user deletes their account. More information 55 | // on revocation can be found here: https://goo.gl/Gx7oEG. 56 | // [START disconnect_tapped] 57 | - (IBAction)didTapDisconnect:(id)sender { 58 | [[GIDSignIn sharedInstance] disconnect]; 59 | } 60 | // [END disconnect_tapped] 61 | 62 | // [START toggle_auth] 63 | - (void)toggleAuthUI { 64 | if ([GIDSignIn sharedInstance].currentUser.authentication == nil) { 65 | // Not signed in 66 | self.statusText.text = @"Google Sign in\niOS Demo"; 67 | self.signInButton.hidden = NO; 68 | self.signOutButton.hidden = YES; 69 | self.disconnectButton.hidden = YES; 70 | } else { 71 | // Signed in 72 | self.signInButton.hidden = YES; 73 | self.signOutButton.hidden = NO; 74 | self.disconnectButton.hidden = NO; 75 | } 76 | } 77 | // [END toggle_auth] 78 | 79 | - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error { 80 | // Perform any operations on signed in user here. 81 | NSString *userId = user.userID; // For client-side use only! 82 | NSString *idToken = user.authentication.idToken; // Safe to send to the server 83 | NSString *name = user.profile.name; 84 | NSString *email = user.profile.email; 85 | NSLog(@"Customer details: %@ %@ %@ %@", userId, idToken, name, email); 86 | // ... 87 | } 88 | 89 | - (UIStatusBarStyle)preferredStatusBarStyle { 90 | return UIStatusBarStyleLightContent; 91 | } 92 | 93 | - (void)dealloc { 94 | [[NSNotificationCenter defaultCenter] 95 | removeObserver:self 96 | name:@"ToggleAuthUINotification" 97 | object:nil]; 98 | 99 | } 100 | 101 | - (void) receiveToggleAuthUINotification:(NSNotification *) notification { 102 | if ([notification.name isEqualToString:@"ToggleAuthUINotification"]) { 103 | [self toggleAuthUI]; 104 | self.statusText.text = notification.userInfo[@"statusText"]; 105 | } 106 | } 107 | @end 108 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/appbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlesamples/google-services/0c2c62a7f54c9158e2598f77c59f09dece68a316/ios/signin/SignInExample/appbg.png -------------------------------------------------------------------------------- /ios/signin/SignInExample/en.lproj/Main.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "UIButton"; normalTitle = "Disconnect"; ObjectID = "8OM-kI-dga"; */ 3 | "8OM-kI-dga.normalTitle" = "Disconnect"; 4 | 5 | /* Class = "UILabel"; text = "Google Sign in iOS Demo"; ObjectID = "BJZ-79-K2W"; */ 6 | "BJZ-79-K2W.text" = "Google Sign in iOS Demo"; 7 | 8 | /* Class = "UIButton"; normalTitle = "Sign out"; ObjectID = "eWa-ii-5oh"; */ 9 | "eWa-ii-5oh.normalTitle" = "Sign out"; 10 | -------------------------------------------------------------------------------- /ios/signin/SignInExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #import 18 | #import "AppDelegate.h" 19 | 20 | int main(int argc, char * argv[]) { 21 | @autoreleasepool { 22 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/signin/SignInExampleSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | import UIKit 17 | import GoogleSignIn 18 | 19 | @UIApplicationMain 20 | // [START appdelegate_interfaces] 21 | class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { 22 | 23 | // [END appdelegate_interfaces] 24 | var window: UIWindow? 25 | 26 | // [START didfinishlaunching] 27 | func application(_ application: UIApplication, 28 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 29 | // Initialize sign-in 30 | GIDSignIn.sharedInstance().clientID = "YOUR_CLIENT_ID" 31 | GIDSignIn.sharedInstance().delegate = self 32 | 33 | return true 34 | } 35 | // [END didfinishlaunching] 36 | 37 | // [START openurl] 38 | func application(_ application: UIApplication, 39 | open url: URL, sourceApplication: String?, annotation: Any) -> Bool { 40 | return GIDSignIn.sharedInstance().handle(url) 41 | } 42 | // [END openurl] 43 | 44 | // [START openurl_new] 45 | @available(iOS 9.0, *) 46 | func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool { 47 | return GIDSignIn.sharedInstance().handle(url) 48 | } 49 | // [END openurl_new] 50 | 51 | // [START signin_handler] 52 | func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, 53 | withError error: Error!) { 54 | if let error = error { 55 | if (error as NSError).code == GIDSignInErrorCode.hasNoAuthInKeychain.rawValue { 56 | print("The user has not signed in before or they have since signed out.") 57 | } else { 58 | print("\(error.localizedDescription)") 59 | } 60 | // [START_EXCLUDE silent] 61 | NotificationCenter.default.post( 62 | name: Notification.Name(rawValue: "ToggleAuthUINotification"), object: nil, userInfo: nil) 63 | // [END_EXCLUDE] 64 | return 65 | } 66 | // Perform any operations on signed in user here. 67 | let userId = user.userID // For client-side use only! 68 | let idToken = user.authentication.idToken // Safe to send to the server 69 | let fullName = user.profile.name 70 | let givenName = user.profile.givenName 71 | let familyName = user.profile.familyName 72 | let email = user.profile.email 73 | // [START_EXCLUDE] 74 | NotificationCenter.default.post( 75 | name: Notification.Name(rawValue: "ToggleAuthUINotification"), 76 | object: nil, 77 | userInfo: ["statusText": "Signed in user:\n\(fullName!)"]) 78 | // [END_EXCLUDE] 79 | } 80 | // [END signin_handler] 81 | 82 | // [START disconnect_handler] 83 | func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, 84 | withError error: Error!) { 85 | // Perform any operations when the user disconnects from app here. 86 | // [START_EXCLUDE] 87 | NotificationCenter.default.post( 88 | name: Notification.Name(rawValue: "ToggleAuthUINotification"), 89 | object: nil, 90 | userInfo: ["statusText": "User has disconnected."]) 91 | // [END_EXCLUDE] 92 | } 93 | // [END disconnect_handler] 94 | } 95 | -------------------------------------------------------------------------------- /ios/signin/SignInExampleSwift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Google Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | import UIKit 17 | import GoogleSignIn 18 | 19 | // Match the ObjC symbol name inside Main.storyboard. 20 | @objc(ViewController) 21 | // [START viewcontroller_interfaces] 22 | class ViewController: UIViewController { 23 | // [END viewcontroller_interfaces] 24 | 25 | // [START viewcontroller_vars] 26 | @IBOutlet weak var signInButton: GIDSignInButton! 27 | @IBOutlet weak var signOutButton: UIButton! 28 | @IBOutlet weak var disconnectButton: UIButton! 29 | @IBOutlet weak var statusText: UILabel! 30 | // [END viewcontroller_vars] 31 | 32 | // [START viewdidload] 33 | override func viewDidLoad() { 34 | super.viewDidLoad() 35 | 36 | GIDSignIn.sharedInstance()?.presentingViewController = self 37 | 38 | // Automatically sign in the user. 39 | GIDSignIn.sharedInstance()?.restorePreviousSignIn() 40 | 41 | // [START_EXCLUDE] 42 | NotificationCenter.default.addObserver(self, 43 | selector: #selector(ViewController.receiveToggleAuthUINotification(_:)), 44 | name: NSNotification.Name(rawValue: "ToggleAuthUINotification"), 45 | object: nil) 46 | 47 | statusText.text = "Initialized Swift app..." 48 | toggleAuthUI() 49 | // [END_EXCLUDE] 50 | } 51 | // [END viewdidload] 52 | 53 | // [START signout_tapped] 54 | @IBAction func didTapSignOut(_ sender: AnyObject) { 55 | GIDSignIn.sharedInstance().signOut() 56 | // [START_EXCLUDE silent] 57 | statusText.text = "Signed out." 58 | toggleAuthUI() 59 | // [END_EXCLUDE] 60 | } 61 | // [END signout_tapped] 62 | 63 | // [START disconnect_tapped] 64 | @IBAction func didTapDisconnect(_ sender: AnyObject) { 65 | GIDSignIn.sharedInstance().disconnect() 66 | // [START_EXCLUDE silent] 67 | statusText.text = "Disconnecting." 68 | // [END_EXCLUDE] 69 | } 70 | // [END disconnect_tapped] 71 | 72 | // [START toggle_auth] 73 | func toggleAuthUI() { 74 | if let _ = GIDSignIn.sharedInstance()?.currentUser?.authentication { 75 | // Signed in 76 | signInButton.isHidden = true 77 | signOutButton.isHidden = false 78 | disconnectButton.isHidden = false 79 | } else { 80 | signInButton.isHidden = false 81 | signOutButton.isHidden = true 82 | disconnectButton.isHidden = true 83 | statusText.text = "Google Sign in\niOS Demo" 84 | } 85 | } 86 | // [END toggle_auth] 87 | 88 | override var preferredStatusBarStyle: UIStatusBarStyle { 89 | return UIStatusBarStyle.lightContent 90 | } 91 | 92 | deinit { 93 | NotificationCenter.default.removeObserver(self, 94 | name: NSNotification.Name(rawValue: "ToggleAuthUINotification"), 95 | object: nil) 96 | } 97 | 98 | @objc func receiveToggleAuthUINotification(_ notification: NSNotification) { 99 | if notification.name.rawValue == "ToggleAuthUINotification" { 100 | self.toggleAuthUI() 101 | if notification.userInfo != nil { 102 | guard let userInfo = notification.userInfo as? [String:String] else { return } 103 | self.statusText.text = userInfo["statusText"]! 104 | } 105 | } 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /ios/signin/SignInExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/signin/SignInExampleTests/SignInExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SignInExampleTests.m 3 | // SignInExampleTests 4 | // 5 | // Created by Ibrahim Ulukaya on 12/15/16. 6 | // Copyright © 2016 Google Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SignInExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SignInExampleTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | EXIT_STATUS=0 6 | 7 | (xcodebuild \ 8 | -workspace ios/${SAMPLE}/${SAMPLE}Example.xcworkspace \ 9 | -scheme ${SAMPLE}Example \ 10 | -sdk iphonesimulator \ 11 | -destination 'platform=iOS Simulator,OS=10.3.1,name=iPhone 7' \ 12 | build \ 13 | test \ 14 | ONLY_ACTIVE_ARCH=YES \ 15 | CODE_SIGNING_REQUIRED=NO \ 16 | | xcpretty) || EXIT_STATUS=$? 17 | 18 | exit $EXIT_STATUS 19 | --------------------------------------------------------------------------------