Skip to content

Instantly share code, notes, and snippets.

View saamerm's full-sized avatar
💭
Answering Questions, & Questioning Answers

Saamer Mansoor saamerm

💭
Answering Questions, & Questioning Answers
View GitHub Profile
@saamerm
saamerm / TimeTrackingService.cs
Created November 30, 2020 16:50
Backgrounding service sample for Android
using System;
using System.Timers;
using Android.App;
using Android.Content;
using Android.OS;
namespace SampleBackgroundServices.Droid
{
public class TimeTrackingService : Service
{
@saamerm
saamerm / InAppReviewService.cs
Last active September 21, 2020 11:28
Native service for an in-app review to display on Android, using the new v1.8 Play Core Library binding for Xamarin
[assembly: Xamarin.Forms.Dependency(typeof(NAMESPACE.Droid.InAppReviewService))]
namespace NAMESPACE.Droid
{
public class InAppReviewService : IInAppReview
{
public void LaunchReview()
{
#if DEBUG
// FakeReviewManager does not interact with the Play Store, so no UI is shown
// and no review is performed. Useful for unit tests.
@saamerm
saamerm / MvxLayoutInflater.cs
Last active November 20, 2020 14:08
MvvmCross 5.2.1 MvxLayoutInflater.cs containing fixes to MvxLayoutInflater.cs from MvvmCross 6.4.1. Check the 4 steps mentioned in the commented code on the top for steps on how to implement this.
/* Steps:
1. Change the targetframework of your android project to Android 10 or above
2. Then add this file to your project either in one file or separate files.
3. Change the namespace from App.Droid to your Android project's namespace.
4. Then in all activities that inherit MvxAppCompatActivity or MvxActivity, add this override and build:
protected override void AttachBaseContext(Context @base)
{
base.AttachBaseContext(MvxContextWrapper2.Wrap(@base, this));
}
*/
@saamerm
saamerm / ButtonPressed.cs
Created July 5, 2020 05:56
Button Pressed Function on
var client = new HttpClient();
var model = new FeedbackModel()
{
Name = NameEntry.Text,
Phone = PhoneEntry.Text,
Email = EmailEntry.Text,
Feedback = FeedbackEntry.Text
};
var uri = "{WebAppUrl}";
var jsonString = JsonConvert.SerializeObject(model);
@saamerm
saamerm / MainPage.xaml
Created July 5, 2020 05:28
Feedback form Xaml code for Xamarin
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" x:Class="XamarinGoogleSheetsDB.MainPage"
BackgroundColor="LightGray">
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Padding="40" WidthRequest="400">
<Label Text="FEEDBACK" FontAttributes="Bold" FontSize="Title"/>
<Entry x:Name="NameEntry" Placeholder="Name" ReturnType="Next" />
<Entry x:Name="EmailEntry" Placeholder="Email" ReturnType="Next" Keyboard="Email" />
@saamerm
saamerm / XamarinToGoogleSheet.gs
Last active July 5, 2020 04:52
Google Apps Script code to accept feedback from Xamarin iOS & Android apps
function doPost(request){
// Open Google Sheet using ID
var sheet = SpreadsheetApp.openById("{SheetID}");
var result = {"Status": "SUCCESS", "Message": "Thank you for your feedback"};
try{
// Convert post data content to a JS object
var resultObject = JSON.parse(request.postData.contents)
// Append data on Google Sheet
var rowData = sheet.appendRow([resultObject.Name, resultObject.Email, resultObject.Phone, resultObject.Feedback]);
}catch(exc){
@saamerm
saamerm / Program.cs
Created January 20, 2020 18:36
Console Application to make a GET String call to a REST API using simple C#!
using System;
using System.Net.Http;
using Newtonsoft.Json;
namespace GetRestAPIJSON
{
class MainClass
{
public static void Main(string[] args)
{
@saamerm
saamerm / TestSMSContactList.json
Created January 20, 2020 16:53
Here's a list of SMS contacts that we want
[
{
"name": "Saamer Mansoor",
"phone": "2146839508",
},
{
"name": "Kamran Shora",
"phone": "+1-416-543-9954",
}
]
@saamerm
saamerm / main.yml
Last active January 12, 2020 18:01
GitHub action yaml for Xamarin Native/Forms Android and iOS apps
name: CI on Push and Pull Request
on: [push, pull_request]
jobs:
Practice:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Run a one-line script
@saamerm
saamerm / SwiftCheatSheet.swift
Created January 3, 2020 09:37
Just another swift cheat sheet
// CheatSheet
// FUNCTIONS
func Main(){
Hello()
}
func Hello(){
print("WHAT")
}
Main()