CrossFirebasePushNotification.Current.RegisterForPushNotifications(); throwing NullReference iOS - xamarin.forms

to do push notifications in my Xamarin Forms App, I am using the CrossGeeks FirebasePushNotification Plugin. My android setup is working alright, but for the iOS app, when I try to run the app, the line
CrossFirebasePushNotification.Current.RegisterForPushNotifications();
is causing a NullReference Exception. What I have done to set up:
Set "FirebaseAppDelegateProxyEnabled" to "No"
Changed the GoogleService plist to Bundle Resource
Added the FirebasePushNotificationManager.Initialize(options, true); in the App Delegate (and it is saying it is unreachable?"
I am testing on a simulator but I believe this should only prevent the receiving of notifications, not the registering?
How would I solve this problem? In the documentation, it states that these are the steps needed for iOS setup.

Related

Data binding not working on iOS device xamarin forms

I am updating a Xamarin App it is working perfectly on Android devices, Android Simulator, and iOS simulator but Not working on iOS devices. I want to test it on the device before launching a new release on Appstore.
I am able to deploy on iOS devices.
The first issue I was facing was in NLogger returning System.NullReferenceException: 'Object reference not set to an instance of an object'
For Logging, I am following
https://martynnw.wordpress.com/2016/10/16/logging-with-nlog-in-xamarin-forms/
tried a lot to resolve the issue did not succeed. so I commented NLogger for Now and used Console.WriteLine("Error: " + ex.Message); just to track/see errors. Here I have raised a question about the NLogger issue.
https://stackoverflow.com/q/71025867/8287839
After commenting NLogger App worked it opened the landing (login) page. But data binding is not working whatever I am filling in the fields it's not being set to the model all parameters are empty. Image paths are Null, Constant variables are null.
On the simulator data binding is working.
How can I resolve this? Do I need to change some kind of permissions or generate a certificate on developer.apple.com?
Here I have uploaded ViewModel, controller, view files.
https://github.com/omshergill/MobileApp

Unity Firebase Crashlytics not sending any crash reports, getting "failed to retrieve settings" error on logcat

Unity editor version: 2019.3.15f1
Firebase Unity SDK version: firebase_unity_sdk_6.15.2
Additional SDKs im using: Unity IAP, Gamesparks, Ironsource, Facebook, Appsflyer, GameAnalytics
Platform im using the Unity editor on: Windows
Platform im targeting: Android
Scripting Runtime: IL2CPP
Problem
I am getting data on firebase analytics, but I cannot get crashlytics to report anything. Im stuck on this...
Steps to reproduce:
Add the firebase analytics and crashlytics sdks.
Add the google-services.json GoogleService-Info.plist files somewhere in assets folder
Add this code to initialise the firebase
// Use this for initialization
void Start ()
{
// Initialize Firebase
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
// Crashlytics will use the DefaultInstance, as well;
// this ensures that Crashlytics is initialized.
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
// Set a flag here for indicating that your project is ready to use Firebase.
VisualDebugger.SetText("crashlytics initialised");
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}",dependencyStatus));
VisualDebugger.SetText("crashlytics NOT initialised: " + dependencyStatus);
// Firebase Unity SDK is not safe to use here.
}
});
Invoke("IsCrashEnabled", 5f);
}
void IsCrashEnabled()
{
VisualDebugger.AddLine("IsCrashlyticsCollectionEnabled: "+Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled);
}
In order to get the app to run with the facebook sdk installed Ive added these two lines to proguard-user.txt
-keep public class com.facebook.**{public *; }
-keep public class com.facebook.internal.**{ public *; }
and commented out the following lines from mainTemplate.gradle
//implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
When I run the app, firebase is initialised successfully. Also Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled returns true.
I crash the app in a number of different ways, then open it again without reinstalling. But no crash reports are sent.
When I watch logcat when starting the app I see this error from firebase each time the app is opened
2020-09-28 16:18:59.332 25773-25847/? E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/REDACTEDblahblahblah/settings
Update Oct 19, 2020:
Today a developer updated the issue I linked in this answer saying the Firebase team fixed a backend bug last Friday (Oct 16) that was affecting some new Unity Android apps registering w/ Firebase - likely the bug behind your issue. I had already solved the issue in my own project using the below solution, but if you haven't yet updated your project, I recommend running it again and seeing if Crashlytics is working for you now..
I've been dealing with the same issue this week in Unity 2019.4.11f1 - i see the same error message about not being able to retrieve settings, but with my specific project and appIds in the URL.
I found a solution in this Github issue, which suggests the problem is caused by the version of an android library that is a dependency for the Unity Firebase Crashlytics package. My rough understanding is that the firebase-crashlytics-unity library is a wrapper around android library firebase:firebase-crashlytics, and the unity package allows the underlying native Android code to be used from Unity. Version com.google.firebase:firebase-crashlytics:17.10.0 has issues with getting the settings for some Firebase projects on Android. Myself and several others following this issue found forcing Unity to use this specific dependency at version 17.1.1 resolved the issue.
Someone else with the same issue in the thread contacted Firebase support and was told:
The error you are seeing "Failed to retrieve settings" is related to
the SDK version being used. If you go to "Assets > Firebase > Editor>
CrashlyticsDependencies" you can manually update the SDK to point to
the latest Crashlytics SDK version 17.2.2. Please give it a try and if
you continue having issues, let me know.
It turned out this advice wasn't quite right - some of us following the thread then experienced a different issue when using the Android Crashlytics SDK version 17.2.2 with Unity crashlytics version 6.16.0. So I'd specifically recommend trying out the below suggestion or other solutions in the thread to set your Android crashlytics library to v17.1.1.
Changes I made in my project to address this:
First, I updated my unity firebase packages in the package manager to use version 6.16.0. In my project 4 packages were installed - core, analytics, crashlytics, and messaging.
Then I searched for the the Crashlytics package's dependency file - Crashlytics-Dependencies.xml (found by searching project - was in /Library/PackageCache/com.google.firebase.crashlytics#6.16.0/Firebase/Editor/ for me). This file initally had "com.google.firebase:firebase-crashlytics:17.0.0" listed, which I updated to be: "com.google.firebase:firebase-crashlytics:17.1.1".
As an extra precaution, I also added created a MyProject-Dependencies.xml file, as was suggested by a user in the thread - this file also specifies version "com.google.firebase:firebase-crashlytics:17.1.1".
Next, I modified the Unity build process to use a custom mainTemplate.gradle file to specify dependencies,
rather than using the External Dependency Resolver to manage and
embed unity packages (option in Build Settings > PlayerSettings >
Android).
I also updated the settings on the External Dependency Manager Android Ressolver:
Disabled AutoResolve and Disabled Resolve on Build (we dont want EDM updating dependencies without our knowledge when building)
I also turned disabled AndroidPackageInstallationEnabled - this has made the resolution process much faster and removed a bunch of .aar files from the android dependencies list, and hasn't caused any problems in my project.
I then ran External Dependency Resolver > Android > Force Resolve, which after the settings changes above, should now embed a list of the dependencies for the Android build into the mainTemplate.gradle file - Check this file (its in Assets/Plugins/Android) and you should now see com.google.firebase:firebase-crashlytics:17.1.1 in that list.
Also, I recommend reading this article about managing Unity Firebase dependencies from one of the Firebase developer advocates, Patrick Martin. It helped me wrap my head around how Android dependency management in Unity works, as well as how the Android gradle build process works.

Replace WebView with WKWebView in Xamarin Forms application

I have a webview inside my Xamarin Forms application which opens report downloaded from server in html format. Today I uploaded my archived application to app store and get information about ITMS-90809: UIWebView API Deprecation.
The problem is that I have no idea how to replace UIWebView with WKWebView in cross platform application. I've tried several solutions:
1) Creating Custom renderer for WebView - but this is no solution really because I need to inherit my new class by WebView superclass. So Apple warn me again with the same message.
2) Creating dependency service and use custom renderer in ios project only. But this is the same problem - there is still WebView reference in shared project.
So, is there any way to inject WKWebView directly to StackLayout in iOS? I know that WKWebView is iOS only and StackLayout is Xamarin.Forms component but really I don't have any idea how to do this.
Can anyone help me?
There is an issue in Github you can follow: Deprecated API Usage UIWebView
WebViewRenderer in iOS implements UIWebView, and the file stays even if you switch over the WkWebViewRenderer. That's why you get the error message.
Xamarin team is working on it and it will fixed sometime in the future.
Also, there is an Apple statement says:
The App Store will no longer accept new apps using UIWebView as of
April 2020 and app updates using UIWebView as of December 2020.
So you can still submit app with UIWebView right now and the error messgae is just a warning.
Relevant links: Make WkWebViewRenderer default for iOS WebView

Firebase Cloud Messaging in Xamarin.Android - Push notification status bar icon not being set correctly

I have a Xamarin.Android application which is registered for push notifications with Firebase. Everything works perfectly when the app is in the foreground. However, when the app is in the background and I send it a notification from the Firebase console, the icon that I've set as the default for notifications is not being used, and Android is using a greyscale version of the application's launcher instead:
And the same goes for the notification in the tray:
This shouldn't be happening, since I have the following line in my AndroidManifest:
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="#drawable/ic_notification" />
And I have monochrome icons in my drawable folders which follow the guidelines detailed by the Android documentation.
I understand the the Firebase console only sends messages without the Data payload, which is why OnMessageReceived in my FirebaseMessagingService is not called when the app is in the background. What I don't understand is why Android is using my launcher icon instead of the one specified in the manifest for notification-payload-only FCM messages.
I am using version 32.961.0 of Xamarin.Firebase.Messaging, since version 42.1001.0 (the latest stable version) has dependencies which break my app in other ways. Is this likely to be an issue with my version of the package, or is there something else I may be doing wrong?
Updating to Xamarin.Firebase.Messaging version 42.1001.0 fixes the issue; it appears to have been a limitation in Firebase Messaging SDK < 9.8.0 (32.961.0 maps to version 9.6.1).

How do you see logging from a Meteor Cordova iOS app?

From what I understand, doing a console.log in a normal Cordova app gets piped to the Xcode debug output, but that doesn't work for my Meteor Cordova iOS app, so I've been doing alerts, which isn't as good.
#Ethaan's answer is a good point, but I don't think it is answering the OP's intended question. I am going to re-iterate the comment from #user728291 on the Question since I believe it is the sought answer.
Safari Remote Debugging will show you console.log messages from
Xcode's simulator or a connected device.
And in the case that the hyper-link may someday be moot, I will re-iterate the referenced text from the link:
If you are doing iOS PhoneGap debugging and have the Safari Develop Menu enabled, you can access the currently active session through the built-in Safari Web Inspector. To activate, go to Develop -> (iPad || iPhone) Simulator (normally, the third menu item) and click the active session you want to connect to. Voila!
The same way you can use Meteor.isServer and Meteor.isClient booleans
to separate your client-side code and server-side code, you can use
Meteor.isCordova constant to separate your Cordova/Phonegap-specific
code from the rest of code shipped to browsers and mobile devices.
From Meteor Cordova Phonegap Integration Documentation
So try with this.
if (Meteor.isCordova) {
console.log('Hi iam on the console from Xcode")
console.log("Welcome back " + Meteor.user().username);
console.log("the user with the id " + Meteor.userId() + " Just logged In");
}

Resources