Skip to content

Commit

Permalink
more work on 28
Browse files Browse the repository at this point in the history
  • Loading branch information
theClarkSell committed Nov 27, 2012
1 parent b483365 commit 67cda5d
Show file tree
Hide file tree
Showing 11 changed files with 523 additions and 29 deletions.
Binary file not shown.

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion source/HTML5/Day28-PushNotifications/app/app/app.jsproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<PackageCertificateKeyFile>Day6_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateKeyFile>app_StoreKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>D5C2E3F4B420B4A463AC9269F32593BD6124139B</PackageCertificateThumbprint>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="app_TemporaryKey.pfx" />
<None Include="app_StoreKey.pfx" />
<Content Include="default.html" />
<Content Include="images\logo.png" />
<Content Include="images\smalllogo.png" />
Expand All @@ -61,6 +64,7 @@
<Content Include="images\WideLogo.png" />
<Content Include="js\default.js" />
<Content Include="css\default.css" />
<None Include="Package.StoreAssociation.xml" />
</ItemGroup>
<ItemGroup>
<SDKReference Include="Microsoft.WinJS.1.0, Version=1.0" />
Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions source/HTML5/Day28-PushNotifications/app/app/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<body>
<div id="content">
<h1>Day #28 - Push Notifications</h1>

<br />
<label contenteditable id="uri"></label>
</div>
</body>
</html>
17 changes: 2 additions & 15 deletions source/HTML5/Day28-PushNotifications/app/app/js/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,8 @@

if (profile.getNetworkConnectivityLevel() === net.NetworkConnectivityLevel.internetAccess) {
push.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync().then(function (channel) {

var postData = { uri: channel.uri };

WinJS.xhr({
type: "POST",
headers: { "Content-Type": "application/json; charset=utf-8" },
url: "http://31daysofwindows8.com/api/PushNotifications",
data: JSON.stringify(postData)
}).then(function (xhr) {
if (xhr.status < 200 || xhr.status >= 300) {
var dialog = new popups.MessageDialog("Unable to open push notification channel");
dialog.showAsync();
}
});
});
document.querySelector("#uri").innerText = channel.uri
})
}

args.setPromise(WinJS.UI.processAll());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name="53657140-d0da-4374-9606-b653e55dfd93" Version="1.0.0.0" Publisher="CN=Clark" />
<Identity Name="32361ClarkSell.ClarkTest" Version="1.0.0.0" Publisher="CN=E52C30A2-E897-42F9-8D37-1F9E26313F35" />
<Properties>
<DisplayName>Day N</DisplayName>
<PublisherDisplayName>Clark</PublisherDisplayName>
<DisplayName>ClarkTest</DisplayName>
<PublisherDisplayName>Clark Sell</PublisherDisplayName>
<Logo>images\storelogo.png</Logo>
</Properties>
<Prerequisites>
Expand All @@ -15,13 +15,14 @@
</Resources>
<Applications>
<Application Id="App" StartPage="default.html">
<VisualElements DisplayName="Day N" Logo="images\logo.png" SmallLogo="images\smalllogo.png" Description="Day N - Topic" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<DefaultTile ShowName="allLogos" />
<VisualElements DisplayName="Day 28" Logo="images\logo.png" SmallLogo="images\smalllogo.png" Description="Day 28 - Topic" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<DefaultTile ShowName="allLogos" WideLogo="images\WideLogo.png" />
<SplashScreen Image="images\splashscreen.png" BackgroundColor="#ff0000" />
</VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<Capability Name="privateNetworkClientServer" />
</Capabilities>
</Package>
Binary file not shown.
105 changes: 105 additions & 0 deletions website/source/push.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
@using NotificationsExtensions;
@using NotificationsExtensions.ToastContent;
@using NotificationsExtensions.TileContent;


@{

if ( IsPost ) {
try {
var sid = Request["sid"];
var secret = Request["secret"];
var uri = Request["uri"];
var message = Request["message"];

WnsAccessTokenProvider tokenProvider = new WnsAccessTokenProvider(sid, secret);

var title = "31 Days";
var subText = message;

var tileNotification = TileContentFactory.CreateTileWideText01();

tileNotification.RequireSquareContent = false;

tileNotification.TextHeading.Text = "31 days";
tileNotification.TextBody1.Text = message;

var tileResult = tileNotification.Send(new Uri(uri), tokenProvider).ErrorDescription;

if (!string.IsNullOrEmpty(tileResult) ){
<h1>tile result: @tileResult</h1>
}

var toastNotification = ToastContentFactory.CreateToastText02();
toastNotification.TextHeading.Text = "31 Days";
toastNotification.TextBodyWrap.Text = message;

var toastResult = toastNotification.Send(new Uri(uri), tokenProvider ).ErrorDescription;

if (!string.IsNullOrEmpty(toastResult) ){
<h1>toast result: @toastResult</h1>
}
}
catch ( Exception e ) {
<h1>@e.Message</h1>
}
}

}

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>31 Days - Push Notification Tester</title>

<style>
ul {
list-style: none;
}
label {
display: block;
}
input {
width: 100%;
}
button {
width: 150px;
}
</style>

</head>
<body>
<form method=post>
<fieldset>
<ul id="formContainer">

<li>
<label>sid:</label>
<input name="sid" type="text">
</li>
<li>
<label>secret:</label>
<input name="secret" type="text">
</li>
<li>
<label>uri:</label>
<input name="uri" type="url">
</li>

<li>
<label>message:</label>
<input name="message" type="text">
</li>
</ul>
<button id="go" type=submit value=submit>send</button>
</fieldset>
</form>
</body>
</html>
41 changes: 34 additions & 7 deletions website/source/web.config
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.diagnostics>
<sources>
<source name="WNSRecipe" switchValue="Off">
<listeners>
<!--
Uncomment one or more entries in this section or add your own custom trace listeners to enable trace logs from the WNS Recipe. Note
that some trace listeners in this section may require additional configuration steps such as configuring output file location, setting
file permissions, creating event sources, etc. For additional information on trace listener configuration, please refer to
http://msdn.microsoft.com/en-us/library/ff664708.aspx and http://msdn.microsoft.com/en-us/library/4y5y10s7.aspx.
-->
<!-- Windows Azure Log -->
<!--<add name="Azure" type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />-->
<!-- Windows Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="WNS Recipe Notifications"/>-->
<!-- Delimited text file -->
<!--<add name="LogFile" type="System.Diagnostics.DelimitedListTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="[TRACE FILE NAME (e.g. c:\temp\sampleDelimitedFile.txt)]" />-->
<!-- XML file -->
<!--<add name="XmlFile" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="c:\temp\sampleLogFile.xml" />-->
<!-- Console -->
<!--<add name="Console" type="System.Diagnostics.ConsoleTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" traceOutputOptions="None"/>-->
</listeners>
</source>
</sources>
</system.diagnostics>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

0 comments on commit 67cda5d

Please sign in to comment.