Created
October 4, 2017 13:47
-
-
Save astjohn/dbec08d730159c68c92a6669339f6f4b to your computer and use it in GitHub Desktop.
xamarin setup for sitata gui
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
// application class | |
namespace YOUR_NAMESPACE { | |
[Application] | |
class YourApp : Application { | |
private static SitataGui MySitataGui { get; set; } | |
public YourApp( IntPtr handle, JniHandleOwnership transfer ) : base( handle, transfer ) { } | |
public override void OnCreate() { | |
base.OnCreate(); | |
// ... | |
} | |
// ... | |
public static void initSitataGui( Context ctx ) { | |
var cfg = new SitataConfig.Builder() | |
.SetApiEndpoint( "https://staging.sitata.com/api/v1/" ) | |
.SetContext( ctx ) | |
.SetAuthToken( "TKN UG...3" ) | |
.SetTripBuilderConfig( new SitataConfig.TripBuilderConfig.Builder() | |
.SetFixedTripDates( true ) | |
.SetSkipTripActivitySelect( true ) | |
.SetSkipTripTypeSelect( true ) | |
.Build() ) | |
.SetFontConfig( new SitataConfig.FontConfig.Builder() | |
// ... | |
.Build() ) | |
.Build(); | |
MySitataGui = new SitataGui( cfg ); | |
} | |
// Creates a singleton pattern for accessing a SitataGui instance. This is | |
// important in situations such as push notifications where an instance must be | |
// present, even before application boot. Using this getter will ensure that | |
// you will always have a properly configured SitataGui instance. | |
public static SitataGui getSitataGui( Context ctx ) { | |
if ( MySitataGui == null ) initSitataGui( ctx ); | |
return MySitataGui; | |
} | |
} | |
} | |
// firebase service: | |
namespace YOUR_NAMESPACE { | |
[Service] | |
[IntentFilter( new[] { "com.google.firebase.MESSAGING_EVENT" } )] | |
class YourFirebaseMessagingService : FirebaseMessagingService { | |
const string TAG = "YourFirebaseMsgService"; | |
public override void OnMessageReceived( RemoteMessage message ) { | |
Log.Debug( TAG, "=============> Got Push From: " + message.From ); | |
var activity = Java.Lang.Object.GetObject<Activity>( JNIEnv.FindClass( "MainActivity" ), JniHandleOwnership.TransferGlobalRef ).Class; | |
SitataController.HandlePushData( YourApp.getSitataGui( this ).Ctrlr, message ); // CHANGES - NOW ONLY SYNCS DATA | |
SitataGui.ShowPushNotification( this, message, Resource.Drawable.ic_info_outline_black_240dp, activity ); // CHANGES - FUNCTION NOW ONLY SHOWS NOTIFICATION | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment