GCM Ok[Debug]

This commit is contained in:
Paul Schneider 2016-07-25 13:17:14 +02:00
commit b2fa0b34e8
16 changed files with 126 additions and 22 deletions

View file

@ -48,7 +48,7 @@ namespace Yavsc.Helpers
request.SendChunked = true;
request.TransferEncoding = "UTF-8";
if (authorizationHeader!=null)
request.Headers.Add($"Authorization: Bearer {authorizationHeader}");
request.Headers.Add($"Authorization: {authorizationHeader}");
}
public static string BasePath { get; private set; } = "http://dev.pschneider.fr/api/";

View file

@ -293,7 +293,8 @@ namespace BookAStar.Droid
public TAnswer InvokeApi<TAnswer>(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(method,
new SimpleJsonPostMethod(
method, "Bearer "+
MainSettings.CurrentUser.YavscTokens.AccessToken
))
{
@ -304,9 +305,10 @@ namespace BookAStar.Droid
public object InvokeApi(string method, object arg)
{
using (var m =
new SimpleJsonPostMethod(method,
new SimpleJsonPostMethod(
method, "Bearer " +
MainSettings.CurrentUser.YavscTokens.AccessToken
))
))
{
return m.InvokeJson(arg);
}

View file

@ -29,13 +29,14 @@
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<permission android:name="com.xamarin.mobilecrm.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="com.xamarin.mobilecrm.permission.MAPS_RECEIVE" />
<permission android:name="fr.pschneider.bas.permission.C2D_MESSAGE" />
<permission android:name="fr.pschneider.bas.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="fr.pschneider.bas.permission.MAPS_RECEIVE" />
<permission android:name="fr.pschneider.bas.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="fr.pschneider.bas.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.intent.RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.intent.REGISTRATION" />
<uses-permission android:name="com.google.android.c2dm.intent.RETRY" />
<uses-permission android:name="android.permission.ACCOUNT_MANAGER" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
</manifest>

View file

@ -44,9 +44,23 @@ namespace BookAStar.Droid
Log.Info ("RegistrationIntentService", "Calling InstanceID.GetToken");
lock (locker)
{
var instanceID = InstanceID.GetInstance (this);
var senderid = MainSettings.GoogleSenderId;
var instanceID = InstanceID.GetInstance(this);
#if DEBUG
try
{
instanceID.DeleteInstanceID();
}
catch(Exception ex)
{
Debug.WaitForDebugger();
Log.Debug("bas.GCM", ex.StackTrace.ToString());
}
#endif
var senderid = MainSettings.GoogleSenderId;
var token = instanceID.GetToken ( senderid,
GoogleCloudMessaging.InstanceIdScope, null);

View file

@ -99,7 +99,7 @@ namespace BookAStar.Droid
void SubscribeGCM ()
{
Context context = this.ApplicationContext;
string senders = "325408689282";
string senders = MainSettings.GoogleSenderId;
// Resources.GetString(GoogleSenderId);
Intent intent = new Intent ("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage ("com.google.android.gsf");

View file

@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View file

@ -90,6 +90,7 @@
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<None Include="app.config" />
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -151,4 +152,4 @@
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
</Target>
</Project>
</Project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View file

@ -86,7 +86,8 @@ namespace BookAStar
public async Task PostDeviceInfo()
{
var res = PlateformSpecificInstance.InvokeApi(
"gcm/register", PlateformSpecificInstance.GetDeviceInfo());
"gcm/register",
PlateformSpecificInstance.GetDeviceInfo());
}
}

View file

@ -58,7 +58,7 @@ namespace BookAStar
};
private static readonly Dictionary<string, double> environ = new Dictionary<string, double>();
public static readonly string YavscApiUrl = "dev.pschneider.fr";
public static readonly string YavscApiUrl = "http://dev.pschneider.fr/api";
#endregion