Skip to content

Commit

Permalink
Updated samples to show new native Safari view controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Clancey committed Sep 20, 2016
1 parent 1f0bcc8 commit 0c91319
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
3 changes: 2 additions & 1 deletion samples/Sample.Forms/Sample.Forms.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
}
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
{
if (SimpleAuth.NativeSafariAuthenticator.ResumeAuth (url.AbsoluteString))
return true;
if (SimpleAuth.Providers.Facebook.OpenUrl(application, url, sourceApplication, annotation))
return true;
return base.OpenUrl(application, url, sourceApplication, annotation);
}

}
}
7 changes: 5 additions & 2 deletions samples/Sample.Forms/Sample.Forms.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>6.0</string>
<string>7.0</string>
<key>CFBundleDisplayName</key>
<string>Sample.Forms</string>
<key>CFBundleIdentifier</key>
Expand Down Expand Up @@ -79,9 +79,12 @@
<string>FB</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb172317429487848</string>
<string>fbclientid</string>
<string>com.googleusercontent.apps.clientid</string>
</array>
</dict>
</array>
<key>CFBundleName</key>
<string>Sample.Forms</string>
</dict>
</plist>
30 changes: 20 additions & 10 deletions samples/Sample.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ public override UIWindow Window
get;
set;
}
GoogleApi googleApi = new GoogleApi("google","clientid","clientsecret");
GoogleApi googleApi = new GoogleApi ("google", "clientid", "clientsecret") {
Scopes = new []
{
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
}
};
ApiKeyApi apiKeyApi = new ApiKeyApi ("myapikey", "api_key", AuthLocation.Query){
BaseAddress = new Uri("http://petstore.swagger.io/v2"),
};
BasicAuthApi basicApi = new BasicAuthApi ("github","https://api.github.com"){UserAgent = "SimpleAuthDemo"};
BasicAuthApi basicApi = new BasicAuthApi ("github","encryptionstring","https://api.github.com"){UserAgent = "SimpleAuthDemo"};
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
SimpleAuth.OnePassword.Activate ();
SimpleAuth.NativeSafariAuthenticator.Activate ();
Api.UnhandledException += (sender, e) =>
{
Console.WriteLine(e);
Expand All @@ -37,13 +44,11 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l

Window.RootViewController = new DialogViewController (new RootElement ("Simple Auth") {
new Section("Google Api"){
new StringElement("Authenticate", () => {
RunWithSpinner("Authenticating",async ()=>{
var account = await googleApi.Authenticate();
ShowAlert("Success","Authenticate");
});
new StringElement("Authenticate", async() => {
var account = await googleApi.Authenticate();
ShowAlert("Success","Authenticate");
}),
new StringElement("Log out", async () => {
new StringElement("Log out", () => {
googleApi.ResetData();
ShowAlert ("Success", "Logged out");
}),
Expand All @@ -60,7 +65,7 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
var account = await basicApi.Authenticate();
ShowAlert ("Success", "Authenticated");
}),
new StringElement("Log out", async () => {
new StringElement("Log out", () => {
basicApi.ResetData();
ShowAlert ("Success", "Logged out");
}),
Expand All @@ -72,7 +77,12 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l

return true;
}

public override bool OpenUrl (UIApplication app, NSUrl url, NSDictionary options)
{
if (NativeSafariAuthenticator.ResumeAuth (url.AbsoluteString))
return true;
return false;
}
async Task RunWithSpinner(string status,Func<Task> task)
{
try{
Expand Down
15 changes: 13 additions & 2 deletions samples/Sample.iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?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>
Expand Down Expand Up @@ -42,5 +42,16 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleName</key>
<string>Sample.iOS</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.88139740130-v4lei65b09c6gn13f152b5dlnokk5d3q</string>
</array>
</dict>
</array>
</dict>
</plist>
</plist>
1 change: 1 addition & 0 deletions samples/Sample.iOS/Sample.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<MtouchArch>i386</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
Expand Down

0 comments on commit 0c91319

Please sign in to comment.