From 7bde905fec2dc9e05230bf0bd8718d9974a8b94a Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Fri, 5 May 2017 14:34:50 -0700 Subject: [PATCH] Updates for Android, use new Flutter registry --- .../storage/FirebaseStoragePlugin.java | 4 +- example/android/app/build.gradle | 4 +- example/android/app/google-services.json | 93 +++++++++++ .../android/app/src/main/AndroidManifest.xml | 2 +- .../android/app/src/main/google-services.json | 144 ------------------ .../MainActivity.java | 2 +- example/android/build.gradle | 1 + example/ios/.gitignore | 1 + example/ios/Runner.xcodeproj/project.pbxproj | 14 +- example/ios/Runner/AppDelegate.m | 11 +- example/ios/Runner/PluginRegistry.h | 20 +++ example/ios/Runner/PluginRegistry.m | 16 ++ ios/Classes/FirebaseStoragePlugin.h | 2 +- 13 files changed, 155 insertions(+), 159 deletions(-) create mode 100644 example/android/app/google-services.json delete mode 100644 example/android/app/src/main/google-services.json rename example/android/app/src/main/java/{com/yourcompany => io/flutter/plugins}/firebase_storage_example/MainActivity.java (88%) create mode 100644 example/ios/Runner/PluginRegistry.h create mode 100644 example/ios/Runner/PluginRegistry.m diff --git a/android/src/main/java/io/flutter/firebase/storage/FirebaseStoragePlugin.java b/android/src/main/java/io/flutter/firebase/storage/FirebaseStoragePlugin.java index 5710d46..fa908c5 100644 --- a/android/src/main/java/io/flutter/firebase/storage/FirebaseStoragePlugin.java +++ b/android/src/main/java/io/flutter/firebase/storage/FirebaseStoragePlugin.java @@ -31,8 +31,8 @@ public class FirebaseStoragePlugin implements MethodCallHandler { private FlutterActivity activity; - public static void register(FlutterActivity activity) { - new FirebaseStoragePlugin(activity); + public static FirebaseStoragePlugin register(FlutterActivity activity) { + return new FirebaseStoragePlugin(activity); } private FirebaseStoragePlugin(FlutterActivity activity) { diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4492592..3ceeab7 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -23,7 +23,7 @@ android { } defaultConfig { - applicationId 'com.yourcompany.firebase_storage' + applicationId 'io.flutter.plugins.firebase_storage_example' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -45,3 +45,5 @@ dependencies { androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test:rules:0.5' } + +apply plugin: 'com.google.gms.google-services' diff --git a/example/android/app/google-services.json b/example/android/app/google-services.json new file mode 100644 index 0000000..2359882 --- /dev/null +++ b/example/android/app/google-services.json @@ -0,0 +1,93 @@ +{ + "project_info": { + "project_number": "297855924061", + "firebase_url": "https://flutterfire-cd2f7.firebaseio.com", + "project_id": "flutterfire-cd2f7", + "storage_bucket": "flutterfire-cd2f7.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:297855924061:android:669871c998cc21bd", + "android_client_info": { + "package_name": "com.yourcompany.firebaseauth.example" + } + }, + "oauth_client": [ + { + "client_id": "297855924061-col4in4uubarifm60nbq8id01ec3ss4c.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.yourcompany.firebaseauth.example", + "certificate_hash": "8a4e194f5bfc3fb1075e7daae8dcddd526fde207" + } + }, + { + "client_id": "297855924061-f68m5v860ms5faiotn5mv9f50cmpacdq.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyD_shO5mfO9lhy2TVWhfo1VUmARKlG4suk" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 2, + "other_platform_oauth_client": [ + { + "client_id": "297855924061-48k2m6hl6pa4q9hukijjd0c20ev4qans.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "com.yourcompany.firebaseAuthExample" + } + }, + { + "client_id": "297855924061-f68m5v860ms5faiotn5mv9f50cmpacdq.apps.googleusercontent.com", + "client_type": 3 + } + ] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:297855924061:android:92efa9a0df6f077f", + "android_client_info": { + "package_name": "io.flutter.plugins.firebase_storage_example" + } + }, + "oauth_client": [ + { + "client_id": "297855924061-f68m5v860ms5faiotn5mv9f50cmpacdq.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyD_shO5mfO9lhy2TVWhfo1VUmARKlG4suk" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 0d825ea..3c9c614 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ diff --git a/example/android/app/src/main/google-services.json b/example/android/app/src/main/google-services.json deleted file mode 100644 index 1897c4e..0000000 --- a/example/android/app/src/main/google-services.json +++ /dev/null @@ -1,144 +0,0 @@ -{ - "project_info": { - "project_number": "569834062290", - "firebase_url": "https://gh-flutter-test.firebaseio.com", - "project_id": "firebase-flutter-test", - "storage_bucket": "firebase-flutter-test.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:569834062290:android:e0c732c7e4a393d5", - "android_client_info": { - "package_name": "org.domokit.sky.shell.SkyApplication" - } - }, - "oauth_client": [ - { - "client_id": "569834062290-rmsctat12epqv98uu2lm2evu43nejh6f.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "org.domokit.sky.shell.SkyApplication", - "certificate_hash": "8a4e194f5bfc3fb1075e7daae8dcddd526fde207" - } - }, - { - "client_id": "569834062290-4f2lq9vvj27dbjbucdbrd0vdej170pr7.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyD349xFuq1iEostYUbBAJWx3J2rVMvbhGs" - } - ], - "services": { - "analytics_service": { - "status": 1 - }, - "appinvite_service": { - "status": 2, - "other_platform_oauth_client": [ - { - "client_id": "569834062290-auhfpjoii1sq0cdi3v3avl1neqao73sd.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.yourcompany.firebaseStorageExample" - } - }, - { - "client_id": "569834062290-4f2lq9vvj27dbjbucdbrd0vdej170pr7.apps.googleusercontent.com", - "client_type": 3 - } - ] - }, - "ads_service": { - "status": 2 - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:569834062290:android:d49a2da736fdf028", - "android_client_info": { - "package_name": "com.yourcompany.app" - } - }, - "oauth_client": [ - { - "client_id": "569834062290-liiupgutb6mkhu0ccpjerd4vc6mmer7t.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.yourcompany.app", - "certificate_hash": "8a4e194f5bfc3fb1075e7daae8dcddd526fde207" - } - }, - { - "client_id": "569834062290-4f2lq9vvj27dbjbucdbrd0vdej170pr7.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyD349xFuq1iEostYUbBAJWx3J2rVMvbhGs" - } - ], - "services": { - "analytics_service": { - "status": 1 - }, - "appinvite_service": { - "status": 2, - "other_platform_oauth_client": [ - { - "client_id": "569834062290-auhfpjoii1sq0cdi3v3avl1neqao73sd.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.yourcompany.firebaseStorageExample" - } - }, - { - "client_id": "569834062290-4f2lq9vvj27dbjbucdbrd0vdej170pr7.apps.googleusercontent.com", - "client_type": 3 - } - ] - }, - "ads_service": { - "status": 2 - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:569834062290:android:b42d1a68758e7b4d", - "android_client_info": { - "package_name": "com.yourcompany.firebase_storage" - } - }, - "oauth_client": [ - { - "client_id": "569834062290-4f2lq9vvj27dbjbucdbrd0vdej170pr7.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyD349xFuq1iEostYUbBAJWx3J2rVMvbhGs" - } - ], - "services": { - "analytics_service": { - "status": 1 - }, - "appinvite_service": { - "status": 1, - "other_platform_oauth_client": [] - }, - "ads_service": { - "status": 2 - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/example/android/app/src/main/java/com/yourcompany/firebase_storage_example/MainActivity.java b/example/android/app/src/main/java/io/flutter/plugins/firebase_storage_example/MainActivity.java similarity index 88% rename from example/android/app/src/main/java/com/yourcompany/firebase_storage_example/MainActivity.java rename to example/android/app/src/main/java/io/flutter/plugins/firebase_storage_example/MainActivity.java index bbf67ab..08b49e2 100644 --- a/example/android/app/src/main/java/com/yourcompany/firebase_storage_example/MainActivity.java +++ b/example/android/app/src/main/java/io/flutter/plugins/firebase_storage_example/MainActivity.java @@ -1,4 +1,4 @@ -package com.yourcompany.firebase_storage_example; +package io.flutter.plugins.firebase_storage_example; import android.os.Bundle; import io.flutter.app.FlutterActivity; diff --git a/example/android/build.gradle b/example/android/build.gradle index ee5325d..2023b0f 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,6 +5,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.google.gms:google-services:3.0.0' } } diff --git a/example/ios/.gitignore b/example/ios/.gitignore index d0a7d98..9cba491 100644 --- a/example/ios/.gitignore +++ b/example/ios/.gitignore @@ -29,6 +29,7 @@ xcuserdata Icon? .tags* +Pods/ /Flutter/app.flx /Flutter/app.zip /Flutter/App.framework diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 10a436f..33ac9b9 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 7A1ECC911E8EDB6900309407 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A1ECC901E8EDB6900309407 /* GoogleService-Info.plist */; }; + 7AF116271EBD2AD800AD0206 /* PluginRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AF116251EBD2AD800AD0206 /* PluginRegistry.m */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; @@ -21,7 +22,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - B1F3D14E8117A6C9F65810E0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D558BB7489B1C82B42A9097 /* libPods-Runner.a */; }; + CE57DC9C9240FBD15E358E24 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E13AAF33B0B411D7B2D38642 /* libPods-Runner.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -42,8 +43,9 @@ /* Begin PBXFileReference section */ 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; - 4D558BB7489B1C82B42A9097 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 7A1ECC901E8EDB6900309407 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + 7AF116251EBD2AD800AD0206 /* PluginRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PluginRegistry.m; sourceTree = ""; }; + 7AF116261EBD2AD800AD0206 /* PluginRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginRegistry.h; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -57,6 +59,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E13AAF33B0B411D7B2D38642 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,7 +69,7 @@ files = ( 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, - B1F3D14E8117A6C9F65810E0 /* libPods-Runner.a in Frameworks */, + CE57DC9C9240FBD15E358E24 /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -116,6 +119,8 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + 7AF116251EBD2AD800AD0206 /* PluginRegistry.m */, + 7AF116261EBD2AD800AD0206 /* PluginRegistry.h */, 7A1ECC901E8EDB6900309407 /* GoogleService-Info.plist */, 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, @@ -139,7 +144,7 @@ CF3B75C9A7D2FA2A4C99F110 /* Frameworks */ = { isa = PBXGroup; children = ( - 4D558BB7489B1C82B42A9097 /* libPods-Runner.a */, + E13AAF33B0B411D7B2D38642 /* libPods-Runner.a */, ); name = Frameworks; sourceTree = ""; @@ -303,6 +308,7 @@ files = ( 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 97C146F31CF9000F007C117D /* main.m in Sources */, + 7AF116271EBD2AD800AD0206 /* PluginRegistry.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m index 8650365..d810189 100644 --- a/example/ios/Runner/AppDelegate.m +++ b/example/ios/Runner/AppDelegate.m @@ -1,15 +1,16 @@ #include "AppDelegate.h" -#include "FirebaseStoragePlugin.h" +#include "PluginRegistry.h" @implementation AppDelegate { - FirebaseStoragePlugin *_firebase_storage; + PluginRegistry *plugins; } -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { FlutterViewController *flutterController = (FlutterViewController *)self.window.rootViewController; - _firebase_storage = [[FirebaseStoragePlugin alloc] initWithController:flutterController]; - return YES; + plugins = [[PluginRegistry alloc] initWithController:flutterController]; + return YES; } @end diff --git a/example/ios/Runner/PluginRegistry.h b/example/ios/Runner/PluginRegistry.h new file mode 100644 index 0000000..eab8486 --- /dev/null +++ b/example/ios/Runner/PluginRegistry.h @@ -0,0 +1,20 @@ +// +// Generated file. Do not edit. +// + +#ifndef PluginRegistry_h +#define PluginRegistry_h + +#import + +#import "FirebaseStoragePlugin.h" + +@interface PluginRegistry : NSObject + +@property (readonly, nonatomic) FirebaseStoragePlugin *firebase_storage; + +- (instancetype)initWithController:(FlutterViewController *)controller; + +@end + +#endif /* PluginRegistry_h */ diff --git a/example/ios/Runner/PluginRegistry.m b/example/ios/Runner/PluginRegistry.m new file mode 100644 index 0000000..72ec168 --- /dev/null +++ b/example/ios/Runner/PluginRegistry.m @@ -0,0 +1,16 @@ +// +// Generated file. Do not edit. +// + +#import "PluginRegistry.h" + +@implementation PluginRegistry + +- (instancetype)initWithController:(FlutterViewController *)controller { + if (self = [super init]) { + _firebase_storage = [[FirebaseStoragePlugin alloc] initWithController:controller]; + } + return self; +} + +@end diff --git a/ios/Classes/FirebaseStoragePlugin.h b/ios/Classes/FirebaseStoragePlugin.h index 915fbea..234c06a 100644 --- a/ios/Classes/FirebaseStoragePlugin.h +++ b/ios/Classes/FirebaseStoragePlugin.h @@ -1,5 +1,5 @@ #import @interface FirebaseStoragePlugin : NSObject -- initWithController:(FlutterViewController *)flutterView; +- initWithController:(FlutterViewController *)controller; @end