This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // BackgroundNoiseAlert.swift | |
| // | |
| // Created by Saamer Mansoor on 2/2/22. | |
| // | |
| import AVFoundation | |
| import UserNotifications | |
| import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import SwiftUI | |
| struct ContentView: View { | |
| @State private var joke: String = "" | |
| var body: some View { | |
| Text(joke) | |
| Button { | |
| Task { | |
| let (data, _) = try await URLSession.shared.data(from: URL(string:"https://api.chucknorris.io/jokes/random")!) | |
| let decodedResponse = try? JSONDecoder().decode(Joke.self, from: data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| private actor JokeServiceStore { | |
| func load() async throws -> String { | |
| let (data, _) = try await URLSession.shared.data(from: URL(string:"https://api.chucknorris.io/jokes/random")!) | |
| let decodedResponse = try? JSONDecoder().decode(Joke.self, from: data) | |
| return decodedResponse?.value ?? "" | |
| } | |
| } | |
| class JokeService: ObservableObject { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Steps to perform migration of MvvmCross using PCL | |
| (primarily done is Visual Studio for Mac) | |
| This tutorial migrates | |
| - PCL .Net solution to .NetStandard, | |
| - MvvmCross 5 solution to MvvmCross 7.1, | |
| - Android to AndroidX | |
| #### The beginning | |
| 1. Create a new repository, with a Migration suffix | |
| 2. Inside it, create a New Blank Native Xamarin Template |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Note: For this to work, you just need to put your spreadsheet ID here in lines 26 and 43 and follow this tutorial https://medium.com/@prototypemakers/simplest-universal-free-game-leaderboard-with-google-sheets-5ab548db009f | |
| // to see the steps for implementing this | |
| // POST and GET API Entry points | |
| // ------------ | |
| function doPost(request){ | |
| var requestObject = JSON.parse(request.postData.contents); | |
| var result = processPostRequest(requestObject); | |
| return ContentService |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Threading.Tasks; | |
| using AppIconUpdater.iOS; | |
| using Xamarin.Forms; | |
| using ui = UIKit.UIApplication; | |
| [assembly: Dependency(typeof(IconSwitchService))] | |
| namespace {YourNamespace}.iOS | |
| { | |
| public class IconSwitchService : IIconSwitchService | |
| { | |
| public async Task SwitchAppIconAsync(string iconName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Android; | |
| using Android.App; | |
| using Android.Media; | |
| using Android.OS; | |
| using Java.IO; | |
| [assembly: Xamarin.Forms.Dependency(typeof(BackgroundRecord.Droid.AudioRecordingService))] | |
| [assembly: UsesPermission(Manifest.Permission.RecordAudio)] | |
| [assembly: UsesPermission(Manifest.Permission.ReadExternalStorage)] | |
| [assembly: UsesPermission(Manifest.Permission.WriteExternalStorage)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Timers; | |
| using Android.App; | |
| using Android.Content; | |
| using Android.OS; | |
| namespace SampleBackgroundServices.Droid | |
| { | |
| public class TimeTrackingService : Service | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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)); | |
| } | |
| */ |