Skip to content

Commit

Permalink
MLIBZ-298 cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
edatkinvey committed May 20, 2015
1 parent cef0b7a commit c19ee5e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
27 changes: 27 additions & 0 deletions Kinvey-Xamarin-iOS/Push/Push.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading;
using Foundation;
using KinveyUtils;
using System.Text.RegularExpressions;

namespace KinveyXamariniOS
{
Expand All @@ -14,12 +15,38 @@ public class Push : AbstractPush

public Push (Client client) : base(client){}

public void RegisterForToken(){
if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (notificationTypes);
} else {
var pushSettings = UIUserNotificationSettings.GetSettingsForTypes (
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet ());

UIApplication.SharedApplication.RegisterUserNotificationSettings (pushSettings);
UIApplication.SharedApplication.RegisterForRemoteNotifications ();
}

}

public void Initialize(string deviceToken){
if (deviceToken == null) {
Logger.Log ("Cannot Initialize for push, device Token cannot be null!");
return;
}

if (deviceToken.StartsWith ("<")) {
deviceToken = deviceToken.Substring (1, deviceToken.Length - 1);
}

if (deviceToken.EndsWith (">")) {
deviceToken = deviceToken.Substring (0, deviceToken.Length - 1);
}

deviceToken = Regex.Replace (deviceToken, @"\s+", "");
deviceToken = deviceToken.ToUpper ();

NSUserDefaults.StandardUserDefaults.SetString(deviceToken, APN_Token);
NSUserDefaults.StandardUserDefaults.Synchronize ();

Expand Down
2 changes: 1 addition & 1 deletion Kinvey-Xamarin/Async/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public virtual Client build() {
if (currentCredential != null){
c.User ().Login (currentCredential, new KinveyDelegate<User> {
onSuccess = (T) => {
Logger.Log("logged in");
//Logger.Log("logged in");
},
onError = (error) => {
Logger.Log(error);
Expand Down
15 changes: 2 additions & 13 deletions Kinvey-Xamarin/Offline/AbstractKinveyOfflineClientRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,13 @@ public override T Execute(){
} else if (policy == OfflinePolicy.LOCAL_FIRST) {
ret = offlineFromStore ();
if (ret == null) {
try {
ret = offlineFromService ();
} catch (Exception e) {
Logger.Log (e);
}
ret = offlineFromService ();
}

} else if (policy == OfflinePolicy.ONLINE_FIRST) {
try {
ret = offlineFromService ();
} catch (Exception e) {
Logger.Log (e);
ret = offlineFromStore ();
}
}
Expand All @@ -183,21 +178,15 @@ public async override Task<T> ExecuteAsync(){
} else if (policy == OfflinePolicy.LOCAL_FIRST) {
ret = await offlineFromStoreAsync ();
if (ret == null) {
try {
ret = await offlineFromServiceAsync ();
} catch (Exception e) {
Logger.Log (e);
}
ret = await offlineFromServiceAsync ();
}

} else if (policy == OfflinePolicy.ONLINE_FIRST) {
bool failed = false;
try {
ret = await offlineFromServiceAsync ();
} catch (Exception e) {
Logger.Log (e);
failed = true;

}
if (failed) {
ret = await offlineFromStoreAsync ();
Expand Down
18 changes: 9 additions & 9 deletions Kinvey-Xamarin/Query/KinveyQueryExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public IEnumerable<T> ExecuteCollection<T>(QueryModel queryModel)
queryModel.Accept (visitor);
writer.Write ("}");

Logger.Log (writer.GetFullString ());
//Logger.Log (writer.GetFullString ());

T[] results = (T[]) queryable.executeQuery (writer.GetFullString ());
foreach (T res in results) {
Expand Down Expand Up @@ -138,14 +138,14 @@ public override void VisitQueryModel (QueryModel queryModel){
protected override void VisitBodyClauses (ObservableCollection<IBodyClause> bodyClauses, QueryModel queryModel)
{
base.VisitBodyClauses (bodyClauses, queryModel);
Logger.Log ("visiting body clause");
//Logger.Log ("visiting body clause");
}

protected override void VisitOrderings (ObservableCollection<Ordering> orderings, QueryModel queryModel, OrderByClause orderByClause)
{
base.VisitOrderings (orderings, queryModel, orderByClause);

Logger.Log ("visiting ordering clause");
//Logger.Log ("visiting ordering clause");
foreach (var ordering in orderings) {
var member = ordering.Expression as MemberExpression;

Expand All @@ -169,7 +169,7 @@ public override void VisitResultOperator (ResultOperatorBase resultOperator, Que
base.VisitResultOperator (resultOperator, queryModel, index);


Logger.Log ("visiting result clause:" + resultOperator.ToString ());
//Logger.Log ("visiting result clause:" + resultOperator.ToString ());
if (resultOperator.ToString ().Contains ("Skip")) {
SkipResultOperator skip = resultOperator as SkipResultOperator;
// Logger.Log (skip.Count);
Expand All @@ -188,7 +188,7 @@ public override void VisitResultOperator (ResultOperatorBase resultOperator, Que

public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index){
base.VisitWhereClause (whereClause, queryModel, index);
Logger.Log ("visiting where clause: " + whereClause.Predicate.ToString());
//Logger.Log ("visiting where clause: " + whereClause.Predicate.ToString());
if (whereClause.Predicate.NodeType.ToString ().Equals ("Equal")) {
BinaryExpression equality = whereClause.Predicate as BinaryExpression;
var member = equality.Left as MemberExpression;
Expand Down Expand Up @@ -242,10 +242,10 @@ public override void VisitWhereClause(WhereClause whereClause, QueryModel queryM

public override void VisitOrderByClause (OrderByClause orderByClause, QueryModel queryModel, int index){
base.VisitOrderByClause (orderByClause, queryModel, index);
Logger.Log ("visiting orderby clause");
foreach (var ordering in orderByClause.Orderings) {
Logger.Log (ordering.Expression);
}
//Logger.Log ("visiting orderby clause");
// foreach (var ordering in orderByClause.Orderings) {
// Logger.Log (ordering.Expression);
// }

}
// public virtual void VisitAdditionalFromClause (AdditionalFromClause fromClause, QueryModel queryModel, int index);
Expand Down
2 changes: 1 addition & 1 deletion RestSharp.Portable/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private async Task<HttpResponse> MakeRequestAsync(HttpMethod method, Cancellatio
Logger.Log ("User-Agent -> (" + this._message.Instance.Headers.UserAgent + ")" );
Logger.Log ("Accepts -> (" + this._message.Instance.Headers.Accept + ")" );
if (this._message.Instance.Content != null){
Logger.Log(this._message.Instance.Content.ToString());
Logger.Log(await this._message.Instance.Content.ReadAsStringAsync());
}

Logger.Log ("------------------------END REQUEST");
Expand Down

0 comments on commit c19ee5e

Please sign in to comment.