Coder Social home page Coder Social logo

localytics-xamarin's Introduction

Localytics Xamarin SDK

This repository contains the open source Xamarin SDK to build the Localytics Xamarin Nuget package (*.nuget). The Localytics Xamarin SDK is a Xamarin wrapper on the native Localytics Android SDK and Localytics iOS SDK. For instruction on how to use the Nuget package, refer to Getting Started

Contents

  • /Localytics-Android-Latest contains the latest Android Release that has been bound to the Xamarin SDK (v6.3.7).
  • /Localytics-iOS-Latest contains the latest iOS Release that has been bound to the Xamarin SDK (v6.2.9).
  • /LocalyticsXamarin contains the entire solution for the Xamarin SDK and sample applications

Building the Nuget Package

This and the following sections are for Developers wishing to contribute to the XamarinSDK. You will need Xcode, and Visual Studio (with Android API 33) and java 8.Simply call make VER=0.0.0 release to build. Localytics recommends using the prebuilt nuget package for integrating Localytics in a production app. Instructions can be found at LocalyticsXamarin/LocalyticsXamarin.NuGet/GettingStarted.md

Build

$ cd LocalyticsXamarin
$ make VER=0.0.0 release

Install locally

$ copy the built nuget package to an appropriate folder and add this folder as a nuget source

Projects in LocalyticsXamarin Solution

The /LocalyticsXamarin folder contain a solution that includes projects for the main libraries and sample/test applications.

LocalyticsXamarin Library Projects

LocalyticsXamarin SDK
LocalyticsXamarin.iOS IOS Xamarin SDK Binding project
LocalyticsXamarin.Android Android Xamarin SDK Binding project
LocalyticsXamarin.Shared Shared Project with code shared between Android and IOS Binding Project
LocalyticsXamarin.Common Common Project that allows access of Xamarin SDK from a Shared project using dependency service.

These projects deal with bindings to the respective Localytics native SDK. To change code in the binding, the native SDK needs to be changed first then updated in the Xamarin project.

  • LocalyticsXamarin.Android (Xamarin.Android Library Binding)

    This project mainly derived from going through possible Transform to fix C# vs Java issues that the tools couldn't dealt with automatically.

  • LocalyticsXamarin.iOS for (Xamarin.iOS Unified Library Binding)

    This project mainly derived from generating bindings through Objective Sharpie with subsequent tweaks.

LocalyticsSample Xamarin.Forms Projects

LocalyticsXamarin SDK Sample Sample to verify the Xamarin SDK API
Android Android Platform project
iOS IOS Platform project
  • LocalyticsSample.iOS deals with native setup, mostly in AppDelegate.cs and Info.plist
  • LocalyticsSample.Android deals with native setup, mostly in LocalyticsAutoIntegrateApplication.cs, MainActivity.cs and AndroidManifest.xml

localytics-xamarin's People

Contributors

azenhom avatar bigbugbb avatar deronbrown avatar druiz avatar jarrodtaylor avatar kbataran avatar matthewpatey avatar mriegel avatar oliviergauthier avatar salmamyassinn avatar saraoabdelhameed avatar thomasvidas avatar tomcurran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

localytics-xamarin's Issues

Android in app messages not showing when triggered from a tagged event

Recently we were trying to use in app campaigns and trigger these from a tagged event in the app. I can see in the Localytics logs that the in app campaign data received by the app is always empty and the test mode campaign list is also empty. I've tested the same thing with an updated Localytics android library and the functionality works. I've created PR #60 which has the updated Android native library included which seems to resolve the issue.

Update makefile to support Java 1.8

When following the instructions to build the component, on a system using pretty much any stable version of Xamarin released this year you will get an error saying the make process doesn't support Java greater than 1.7.

Considering that Java 1.8 is pretty much a requirement for Xamarin development these days, it would probably be a good idea to update the build process.

Latest LocalyticsXamarin nuget package relies on Xamarin.Forms and LocalyticsSample projects

I just removed all nuget packages from my Xamarin iOS Project to start fresh re-adding them to the project file itself instead of using a packages.json file. When I added the LocalyticsXamarin nuget package (5.8.0), it gave build errors related to a LocalyticsXamarinForms.cs file:

/Users/justintoth/.nuget/packages/localyticsxamarin/5.8.0/contentFiles/any/any/LocalyticsXamarinForms.cs(20,20): Error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?) (CS0234) (com.rpr.mobile.ios.lib)
/Users/justintoth/.nuget/packages/localyticsxamarin/5.8.0/contentFiles/any/any/LocalyticsXamarinForms.cs(7,7): Error CS0246: The type or namespace name 'LocalyticsSample' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (com.rpr.mobile.ios.lib)
/Users/justintoth/.nuget/packages/localyticsxamarin/5.8.0/contentFiles/any/any/LocalyticsXamarinForms.cs(71,71): Error CS0246: The type or namespace name 'IPlatform' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (com.rpr.mobile.ios.lib)

When inspecting this file, it depends on including the Xamarin.Forms nuget package, which doesn't make sense when working on a vanilla Xamarin.iOS project. It also relies on LocalyticsSample, which isn't found so obviously isn't being included in the nuget package. Can someone please resolve these issues and release a buildable LocalyticsXamarin nuget package?

App keeps crashes on LLAppDelegateProxy with AutoIntegrate

I keep getting crashes on start up whenever I called Localytics.AutoIntegrate in my Xamarin Forms app on a Release build. On a Debug build, the call seems to be OK. It complains about LLAppDelegateProxy does not seem to derive from any known ObjectiveC class.

Would you be able to let me know if I miss anything in the configuration to be able to call AutoIntegrate? The Xamarin Forms sample app from this repository seems to be working fine both on Debug and Release mode.

The complete stack trace is as follows:

Jan 25 09:29:05 AS01MACE480714 Pulse.iOS[1639]: Unhandled managed exception:
The ObjectiveC class 'LLAppDelegateProxy' could not be registered, it does not seem to derive from any known ObjectiveC class (including NSObject). (ObjCRuntime.RuntimeException)
at Registrar.DynamicRegistrar.Lookup (IntPtr class, Boolean throw_on_error) <0x165478e8 + 0x001db> in :0
at ObjCRuntime.Class.Lookup (IntPtr klass, Boolean throw_on_error) <0x165478b8 + 0x00027> in :0
at ObjCRuntime.Class.Lookup (IntPtr klass) <0x16547888 + 0x0001b> in :0
at ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution) <0x1654a588 + 0x00013> in :0
at ObjCRuntime.Runtime.GetNSObject (IntPtr ptr, MissingCtorResolution missingCtorResolution, Boolean evenInFinalizerQueue) <0x1654a510 + 0x0005b> in :0
at ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) <0x1654a4d8 + 0x00023> in :0
at UIKit.UIApplication.get_WeakDelegate () <0x1a04ed60 + 0x00053> in :0
at UIKit.UIApplication.get_Delegate () <0x1a04ed08 + 0x00016> in :0
at Xamarin.InsightsCore.UIObserver.ObserveStoryBoardUI () <0x1a04ead0 + 0x0002f> in :0
at Foundation.NSAsyncActionDispatcher.Apply () <0x1a03e290 + 0x00014> in :0
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) <0x18968740 + 0x0002b> in :0
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x189686a0 + 0x00087> in :0

AnalyticsHandler _tagEvent exception on Xamarin Android

In our Xamarin Android app we're getting hundreds of crashes that are internal to the Localytics SDK. We're using the latest version, 5.5.0. Can this be fixed in a future SDK update?

com.localytics.android.AnalyticsHandler._tagEvent
AnalyticsHandler.java, line 1235
java.lang.IncompatibleClassChangeError: Class 'java.lang.VirtualMachineError' does not implement interface 'java.lang.CharSequence' in call to 'int java.lang.CharSequence.length()' (declaration of 'java.lang.Throwable' appears in /system/framework/core-libart.jar)
com.localytics.android.AnalyticsHandler._tagEvent AnalyticsHandler.java:1235
com.localytics.android.AnalyticsHandler.access$100 AnalyticsHandler.java:51
com.localytics.android.AnalyticsHandler$5.run AnalyticsHandler.java:588
com.localytics.android.BaseProvider.runBatchTransaction BaseProvider.java:409
com.localytics.android.BaseHandler._runBatchTransactionOnProvider BaseHandler.java:191
com.localytics.android.AnalyticsHandler.handleMessageExtended AnalyticsHandler.java:577
com.localytics.android.BaseHandler.handleMessage BaseHandler.java:173
android.os.Handler.dispatchMessage Handler.java:102

Can't resolve the reference 'Foundation.NSArray Foundation.NSArray::FromNSObjects(!!0[])

After upgrading our Localytics Xamarin iOS package from 5.5.0 to 5.6.0, our App Center automated builds now fail:

MTOUCH : error MT2101: Can't resolve the reference 'Foundation.NSArray Foundation.NSArray::FromNSObjects(!!0[])', referenced from the method 'System.Void LocalyticsXamarin.IOS.Localytics::TriggerRegions(CoreLocation.CLRegion[],LocalyticsXamarin.IOS.LLRegionEvent,CoreLocation.CLLocation)' in 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. [/Users/vsts/agent/2.154.3/work/1/s/ios-application/org.narrpr.mobile.ios.app.csproj]

Building locally in either debug or release mode works, it only fails in the automated builds.

Unneeded Firebase services and receivers are not being disabled

In the native version of the library, it seems like some Firebase services and receivers get disabled depending on the user configuration:

<service android:enabled="@bool/ll_fcm_push_services_enabled" android:exported="true" android:name="com.localytics.android.FirebaseService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

In the example shown above, the service com.localytics.android.FirebaseService will only be enabled in the manifest if ll_fcm_push_services_enabled is set to true.

However, this doesn't seem to be the case on the Xamarin version of the library, as the values set in the configuration don't seem to be used in the manifest at all.

Suggestion: Remove optional dependencies from the NuGet specification

In the version of Localytics for native Android, some optional dependencies are not added by default. Instead, the user is expected to add them manually if they want Localytics to make use of them. For example, com.google.firebase:firebase-messaging is not added as a dependency automatically, and it is the user's responsibility to add it if they decide to set ll_fcm_push_services_enabled to true.

It would be great if this same idea were applied in the Xamarin version of the library. Right now, all the optional dependencies are added by default with the NuGet package even if they are not needed, which is not ideal.

Remove mandatory Google AdMob dependency and configuration requirement for Xamarin Android library

Version 6.0.4 of the Xamarin Android nuget package requires a Google AdMob app ID configured and a run time exception is thrown if it is not configured. This is not required when using the native Android Localytics library and we'd like to be able to exclude this when using the Xamarin library.

To reproduce run the latest sample android app.

The run time error that is thrown is shown below:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 
[MonoDroid] 
[MonoDroid] ******************************************************************************
[MonoDroid] * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
[MonoDroid] * should follow the instructions here:                                       *
[MonoDroid] * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
[MonoDroid] * to add a valid App ID inside the AndroidManifest.                          *
[MonoDroid] * Google Ad Manager publishers should follow instructions here:              *
[MonoDroid] * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
[MonoDroid] ******************************************************************************
[MonoDroid] 
[MonoDroid]  ---> Java.Lang.IllegalStateException: 
[MonoDroid] 
[MonoDroid] ******************************************************************************
[MonoDroid] * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
[MonoDroid] * should follow the instructions here:                                       *
[MonoDroid] * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
[MonoDroid] * to add a valid App ID inside the AndroidManifest.                          *
[MonoDroid] * Google Ad Manager publishers should follow instructions here:              *
[MonoDroid] * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
[MonoDroid] ******************************************************************************
[MonoDroid] 
[MonoDroid] 
[MonoDroid]    --- End of inner exception stack trace ---
[MonoDroid]   --- End of managed Java.Lang.RuntimeException stack trace ---
[MonoDroid] java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 
[MonoDroid] 
[MonoDroid] ******************************************************************************
[MonoDroid] * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
[MonoDroid] * should follow the instructions here:                                       *
[MonoDroid] * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
[MonoDroid] * to add a valid App ID inside the AndroidManifest.                          *
[MonoDroid] * Google Ad Manager publishers should follow instructions here:              *
[MonoDroid] * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
[MonoDroid] ******************************************************************************
[MonoDroid] 
[MonoDroid] 
[MonoDroid] 	at android.app.ActivityThread.installProvider(ActivityThread.java:7244)
[MonoDroid] 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
[MonoDroid] 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
[MonoDroid] 	at android.app.ActivityThread.access$1300(ActivityThread.java:237)
[MonoDroid] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
[MonoDroid] 	at android.os.Handler.dispatchMessage(Handler.java:106)
[MonoDroid] 	at android.os.Looper.loop(Looper.java:223)
[MonoDroid] 	at android.app.ActivityThread.main(ActivityThread.java:7656)
[MonoDroid] 	at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[MonoDroid] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
[MonoDroid] Caused by: java.lang.IllegalStateException: 
[MonoDroid] 
[MonoDroid] ******************************************************************************
[MonoDroid] * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
[MonoDroid] * should follow the instructions here:                                       *
[MonoDroid] * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
[MonoDroid] * to add a valid App ID inside the AndroidManifest.                          *
[MonoDroid] * Google Ad Manager publishers should follow instructions here:              *
[MonoDroid] * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
[MonoDroid] ******************************************************************************
[MonoDroid] 
[MonoDroid] 
[MonoDroid] 	at com.google.android.gms.internal.ads.zzzt.attachInfo(com.google.android.gms:play-services-ads-lite@@19.7.0:31)
[MonoDroid] 	at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@19.7.0:3)
[MonoDroid] 	at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
[MonoDroid] 	... 10 more
[MonoDroid] 

Latest LocalyticsXamarin nuget package relies on Xamarin.Forms and LocalyticsSample projects

Since my original ticket was closed even though the issue still exists, I'm creating a new one with the same details... It's disappointing that I reported this 6 months ago and no one has taken it seriously, it shows that there is absolutely no one using Xamarin and Localytics. Furthermore, it's clear that the Localytics developers don't understand the difference between native Xamarin iOS / Xamarin Android apps and Xamarin Forms apps.

I just removed all nuget packages from my Xamarin iOS Project to start fresh re-adding them to the project file itself instead of using a packages.json file. When I added the LocalyticsXamarin nuget package (5.8.0), it gave build errors related to a LocalyticsXamarinForms.cs file:

/Users/justintoth/.nuget/packages/localyticsxamarin/5.8.0/contentFiles/any/any/LocalyticsXamarinForms.cs(20,20): Error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?) (CS0234) (com.rpr.mobile.ios.lib)
/Users/justintoth/.nuget/packages/localyticsxamarin/5.8.0/contentFiles/any/any/LocalyticsXamarinForms.cs(7,7): Error CS0246: The type or namespace name 'LocalyticsSample' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (com.rpr.mobile.ios.lib)
/Users/justintoth/.nuget/packages/localyticsxamarin/5.8.0/contentFiles/any/any/LocalyticsXamarinForms.cs(71,71): Error CS0246: The type or namespace name 'IPlatform' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (com.rpr.mobile.ios.lib)

When inspecting this file, it depends on including the Xamarin.Forms nuget package, which doesn't make sense when working on a vanilla Xamarin.iOS project. It also relies on LocalyticsSample, which isn't found so obviously isn't being included in the nuget package. Can someone please resolve these issues and release a buildable LocalyticsXamarin nuget package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.