forked from mono/monotouch-bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GooglePlayAndPlus] Added Sample App
- Loading branch information
Showing
12 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
GooglePlusAndPlayGameServices/samples/GooglePlusSample/GooglePlusSample.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GooglePlusSample", "GooglePlusSample\GooglePlusSample.csproj", "{1DEFD334-E144-43EF-B577-4DE53F4BE241}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|iPhoneSimulator = Debug|iPhoneSimulator | ||
Release|iPhoneSimulator = Release|iPhoneSimulator | ||
Debug|iPhone = Debug|iPhone | ||
Release|iPhone = Release|iPhone | ||
Ad-Hoc|iPhone = Ad-Hoc|iPhone | ||
AppStore|iPhone = AppStore|iPhone | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.AppStore|iPhone.ActiveCfg = AppStore|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.AppStore|iPhone.Build.0 = AppStore|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Debug|iPhone.ActiveCfg = Debug|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Debug|iPhone.Build.0 = Debug|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Release|iPhone.ActiveCfg = Release|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Release|iPhone.Build.0 = Release|iPhone | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator | ||
{1DEFD334-E144-43EF-B577-4DE53F4BE241}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator | ||
EndGlobalSection | ||
GlobalSection(MonoDevelopProperties) = preSolution | ||
StartupItem = GooglePlusSample\GooglePlusSample.csproj | ||
EndGlobalSection | ||
EndGlobal |
85 changes: 85 additions & 0 deletions
85
GooglePlusAndPlayGameServices/samples/GooglePlusSample/GooglePlusSample/AppDelegate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using MonoTouch.Foundation; | ||
using MonoTouch.UIKit; | ||
|
||
using Google.Plus; | ||
|
||
namespace GooglePlusSample | ||
{ | ||
// The UIApplicationDelegate for the application. This class is responsible for launching the | ||
// User Interface of the application, as well as listening (and optionally responding) to | ||
// application events from iOS. | ||
[Register ("AppDelegate")] | ||
public partial class AppDelegate : UIApplicationDelegate | ||
{ | ||
// class-level declarations | ||
UIWindow window; | ||
MainViewController viewController; | ||
UINavigationController navController; | ||
|
||
// TODO: | ||
// Before you can use Google Plus SDK and run this sample, | ||
// you must create an APIs Console project at | ||
// https://developers.google.com/console | ||
// make sure you use com.xamarin.googleplussample as your Bundle ID on Google's portal. | ||
// More info on how to setup https://developers.google.com/+/mobile/ios/getting-started | ||
|
||
const string ClientId = "YOUR_CLIENT_ID"; | ||
|
||
// | ||
// This method is invoked when the application has loaded and is ready to run. In this | ||
// method you should instantiate the window, load the UI into it and then make the window | ||
// visible. | ||
// | ||
// You have 17 seconds to return from this method, or iOS will terminate your application. | ||
// | ||
public override bool FinishedLaunching (UIApplication app, NSDictionary options) | ||
{ | ||
window = new UIWindow (UIScreen.MainScreen.Bounds); | ||
|
||
// Configure the SignIn shared singleton instance by declaring | ||
// its client ID, delegate, and scopes. | ||
var signIn = SignIn.SharedInstance; | ||
signIn.ClientId = ClientId; | ||
signIn.Scopes = new [] { PlusConstants.AuthScopePlusLogin, PlusConstants.AuthScopePlusMe }; | ||
|
||
// If you want to know user Email or Google User Id you should | ||
// Set ShouldFetchGoogleUserEmail or ShouldFetchGoogleUserId | ||
// value to true, default value is false | ||
signIn.ShouldFetchGoogleUserEmail = true; | ||
signIn.ShouldFetchGoogleUserId = true; | ||
|
||
// Setup event listener when user logins | ||
signIn.Finished += HandleFinished; | ||
|
||
viewController = new MainViewController (); | ||
navController = new UINavigationController (viewController); | ||
|
||
window.RootViewController = navController; | ||
window.MakeKeyAndVisible (); | ||
|
||
return true; | ||
} | ||
|
||
void HandleFinished (object sender, SignInDelegateFinishedEventArgs e) | ||
{ | ||
if (e.Error != null) { | ||
InvokeOnMainThread (()=> new UIAlertView ("Error", "Could not sign in.\nError: " + e.Error.Description, null, "Ok", null).Show ()); | ||
} else { | ||
Console.WriteLine ("Success\nToken: " + SignIn.SharedInstance.Authentication.AccessToken); | ||
Console.WriteLine ("Email: " + SignIn.SharedInstance.UserEmail); | ||
navController.PushViewController (new DVCMenu(), true); | ||
} | ||
} | ||
|
||
public override bool OpenUrl (UIApplication application, NSUrl url, string sourceApplication, NSObject annotation) | ||
{ | ||
// This handler will properly handle the URL that your application | ||
// receives at the end of the authentication process. | ||
return UrlHandler.HandleUrl (url, sourceApplication, annotation); | ||
} | ||
} | ||
} | ||
|
134 changes: 134 additions & 0 deletions
134
GooglePlusAndPlayGameServices/samples/GooglePlusSample/GooglePlusSample/DVCMenu.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using MonoTouch.Foundation; | ||
using MonoTouch.UIKit; | ||
using MonoTouch.Dialog; | ||
|
||
using Google.Plus; | ||
using Google.OpenSource; | ||
|
||
namespace GooglePlusSample | ||
{ | ||
public partial class DVCMenu : DialogViewController | ||
{ | ||
ServicePlus plusService; | ||
//QueryPlus query; | ||
|
||
public DVCMenu () : base (UITableViewStyle.Grouped, null) | ||
{ | ||
Root = new RootElement ("Google+ Sample") { | ||
new Section () { | ||
new StyledStringElement ("Email", SignIn.SharedInstance.UserEmail, UITableViewCellStyle.Subtitle) | ||
}, | ||
new Section () { | ||
new StringElement ("Get User Information", GetUserInfo) { | ||
Alignment = UITextAlignment.Center | ||
}, | ||
new StringElement ("Share Xamarin.com", HandleShareUrl) { | ||
Alignment = UITextAlignment.Center | ||
}, | ||
new StringElement ("Share your love for XamarinStudio", HandleShareXS) { | ||
Alignment = UITextAlignment.Center | ||
}, | ||
new StringElement ("List people in your circles", GetUserPeople) { | ||
Alignment = UITextAlignment.Center | ||
} | ||
}, | ||
new Section () { | ||
new StringElement ("Logout", ()=> { | ||
SignIn.SharedInstance.SignOut (); | ||
NavigationController.PopViewControllerAnimated (true); | ||
}) { | ||
Alignment = UITextAlignment.Center | ||
}, | ||
new StringElement ("Logout and Revoke Access Token", ()=> { | ||
SignIn.SharedInstance.Disconnect (); | ||
NavigationController.PopViewControllerAnimated (true); | ||
}) { | ||
Alignment = UITextAlignment.Center | ||
}, | ||
} | ||
}; | ||
} | ||
|
||
void HandleShareUrl () | ||
{ | ||
// When you share a URL, the title, description, thumbnail image and link | ||
// for the share dialog are based on the URL you provide. | ||
var shareBuilder = Share.SharedInstance.ShareDialog; | ||
shareBuilder.SetURLToShare (new NSUrl ("http://xamarin.com")); | ||
shareBuilder.Open (); | ||
} | ||
|
||
void HandleShareXS () | ||
{ | ||
// This line will manually fill out the title, description, and | ||
// thumbnail of the item you're sharing. | ||
var shareBuilder = Share.SharedInstance.ShareDialog; | ||
shareBuilder.SetTitle (title: "I love coding on Xanarin Studio!!", | ||
description: "Xamarin Studio is the best development environment for cross-platform mobile apps. Available on Windows and Mac.", | ||
thumbnailUrl: new NSUrl ("http://xamarin.com/images/studio/screenshot1.jpg")); | ||
|
||
// For more information about SetContentDeepLinkId visit | ||
// https://developers.google.com/+/mobile/ios/share#deep_linking | ||
shareBuilder.SetContentDeepLinkId ("XamarinStudio"); | ||
shareBuilder.Open (); | ||
} | ||
|
||
void GetUserPeople () | ||
{ | ||
plusService = new ServicePlus () { | ||
RetryEnabled = true, | ||
Authorizer = SignIn.SharedInstance.Authentication | ||
}; | ||
|
||
// The following example uses the visible (PlusConstants.PlusCollectionVisible) collection to obtain a list of people | ||
// who the signed-in user has added to one or more circles, which is limited to the circles the | ||
// user made visible to the requesting app. This list does not include names of circles. | ||
var query = QueryPlus.QueryForPeopleListWithUserId ("me", PlusConstants.PlusCollectionVisible); | ||
plusService.ExecuteQuery (query, (ticket, obj, error) => { | ||
// obj contains the query results, we must cast it to PlusPeopleFeed in order to get its information | ||
var peopleFeed = obj as PlusPeopleFeed; | ||
if (error != null) | ||
InvokeOnMainThread (() => new UIAlertView ("Error", error.Description, null, "Ok", null).Show ()); | ||
else { | ||
var root = new RootElement ("People List") { new Section () }; | ||
foreach (var person in peopleFeed.Items) { | ||
root[0].Add (new StringElement (person.DisplayName)); | ||
} | ||
var dvc = new DialogViewController (root, true); | ||
InvokeOnMainThread (() => NavigationController.PushViewController (dvc, true)); | ||
} | ||
}); | ||
} | ||
|
||
void GetUserInfo () | ||
{ | ||
plusService = new ServicePlus () { | ||
RetryEnabled = true, | ||
Authorizer = SignIn.SharedInstance.Authentication | ||
}; | ||
|
||
// Create a QueryPlus object to get the details of the user with the given user ID. | ||
// The special value "me" indicates the currently signed in user, but you could use | ||
// any other valid user ID. Returns a PlusPerson. | ||
var query = QueryPlus.QueryForPeopleGetWithUserId ("me"); | ||
plusService.ExecuteQuery (query, (ticket, obj, error) => { | ||
// obj contains the query results, we must cast it to PlusPerson in order to get its information | ||
var person = obj as PlusPerson; | ||
if (error != null) | ||
InvokeOnMainThread (() => new UIAlertView ("Error", error.Description, null, "Ok", null).Show ()); | ||
else { | ||
InvokeOnMainThread (() => { | ||
var section = Root[0]; | ||
section.Add (new StyledStringElement ("Display Name", person.DisplayName, UITableViewCellStyle.Subtitle)); | ||
section.Add (new StyledMultilineElement ("About Me", person.AboutMe, UITableViewCellStyle.Subtitle)); | ||
section.Add (new StyledStringElement ("Birthday", person.Birthday, UITableViewCellStyle.Subtitle)); | ||
ReloadData (); | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
...PlusAndPlayGameServices/samples/GooglePlusSample/GooglePlusSample/GooglePlusSample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform> | ||
<ProductVersion>10.0.0</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{1DEFD334-E144-43EF-B577-4DE53F4BE241}</ProjectGuid> | ||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>GooglePlusSample</RootNamespace> | ||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix> | ||
<AssemblyName>GooglePlusSample</AssemblyName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
<MtouchLink>None</MtouchLink> | ||
<MtouchDebug>true</MtouchDebug> | ||
<MtouchI18n /> | ||
<MtouchArch>ARMv7</MtouchArch> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
<MtouchLink>None</MtouchLink> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\iPhone\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
<MtouchDebug>true</MtouchDebug> | ||
<CodesignKey>iPhone Developer</CodesignKey> | ||
<MtouchI18n /> | ||
<MtouchArch>ARMv7</MtouchArch> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhone\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
<CodesignKey>iPhone Developer</CodesignKey> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<BuildIpa>true</BuildIpa> | ||
<CodesignKey>iPhone Distribution</CodesignKey> | ||
<ConsolePause>false</ConsolePause> | ||
<CodesignProvision>Automatic:AdHoc</CodesignProvision> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhone\AppStore</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
<CodesignKey>iPhone Distribution</CodesignKey> | ||
<CodesignProvision>Automatic:AppStore</CodesignProvision> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="monotouch" /> | ||
<Reference Include="Google.Plus"> | ||
<HintPath>..\..\..\binding\Google.Plus.dll</HintPath> | ||
</Reference> | ||
<Reference Include="MonoTouch.Dialog-1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Resources\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Info.plist" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Main.cs" /> | ||
<Compile Include="AppDelegate.cs" /> | ||
<Compile Include="MainViewController.cs" /> | ||
<Compile Include="DVCMenu.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<ItemGroup> | ||
<BundleResource Include="Resources\Default-568h%402x.png" /> | ||
<BundleResource Include="Resources\Default%402x~iphone.png" /> | ||
<BundleResource Include="Resources\Default~iphone.png" /> | ||
<BundleResource Include="Resources\Icon.png" /> | ||
<BundleResource Include="Resources\Icon%402x.png" /> | ||
</ItemGroup> | ||
</Project> |
25 changes: 25 additions & 0 deletions
25
GooglePlusAndPlayGameServices/samples/GooglePlusSample/GooglePlusSample/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
</array> | ||
<key>CFBundleURLTypes</key> | ||
<array> | ||
<dict> | ||
<key>CFBundleURLName</key> | ||
<string>com.xamarin.googleplussample</string> | ||
<key>CFBundleURLSchemes</key> | ||
<array> | ||
<string>com.xamarin.googleplussample</string> | ||
</array> | ||
<key>CFBundleURLTypes</key> | ||
<string>Editor</string> | ||
</dict> | ||
</array> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.xamarin.googleplussample</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.