Accessing Android activity object during app startup - Nativescript - nativescript

Before I upgraded to NS 3.4, I used to call the following function in the app start-page's navigatingTo method
application.android.foregroundActivity.getResources()
But looks like now in 3.4 - foregroundActivity is undefined - at least while the app is starting up.
Is there an alternate solution?

We can use
application.android.startActivity
However, there was a discussion about the changes in foregroundActivity and startActivity and the updated information about how those will react in the upcoming NativeScript can be found in this thread

Related

Quickblox.sdk GetBaseSession() method throws "nonce is required" error

I have used quickblox chat sdk in my old xamarin.forms project. I know that quickblox is not supporting xamarin now, but old sdk was working fine till now, but from last week I am getting this error.
Code:
var baseSesionResult = await Provider.QbProvider.GetBaseSession();
When I am calling QbProvider.GetBaseSession() it throws below error:
CONTENT: {"errors":{"base":["nonce is required"]}}
I have tried different methods available in sdk but none is working. Any one know how to fix this error?
This is Nikolay from QuickBlox support.
Please add "" symbols around nonce and timestamp values and check if the issue is resolved.
The same information is mentioned in our documentation: https://docs.quickblox.com/reference/authentication#create-session
We released a patch for authentication that improves validation according to our documentation.
Hence, the issue is caused by incorrect implementation in the application that is why the server has started showing errors for submitted requests.

tns preview doesn't work doe to unexpected token

Project successfully prepared (ios)
Start sending initial files for device iPhone.
Successfully sent initial files for device iPhone.
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse ()
at PreviewSdkService. (/usr/local/lib/node_modules/nativescript/lib/services/livesync/playground/preview-sdk-service.js:100:43)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/nativescript/lib/services/livesync/playground/preview-sdk-service.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
hey i have exact the same error on same position in preview-sdk-service.js i reinstalled everything with no errors but still the same. i contacted the support, when i get an answer i will let you know. i have also problems with playground today it will not load correctly on my device. btw yesterday it worked like a charm.
---------SUPPORT ANSWER--------------
"we are migrating the auth to use Firebase and looks like couple things are still propagating. An engineer is working on this and should be resolved by Monday"
so its not a user mistake and we can just wait and hope they can fix it quickly.
I'm running into this exact issue at the moment. Even started a new template using the Angular CLI command:
ng new --collection=#nativescript/schematics my-mobile-app
From the site:
Angular CLI support
The initial template seem to work but after adding some custom modules this started happening. Running on a Android Virtual Device works.
I've been looking for a solution and the issues seems to ga back as far as 2018 so i'm not sure if this is even een NativeScript issues of a dev environment issues not being setup correctly.

“No map found” error when running NativeScript Angular 2 app

I’ve got a really weird error when trying to run an app built with NativeScript and Angular 2. Here’s the error:
CONSOLE ERROR file:///app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:342:26:
Unhandled Promise rejection: No map found ; Zone: angular ; Task: Promise.then ; Value: No map found undefined
CONSOLE ERROR file:///app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:344:22:
Error: Uncaught (in promise): No map found
The error occurs when the app starts up. I’m using nativescript-angular version 1.1.2 and I’m including zone.js version 0.6.21 in my devDependencies. Here’s my full package.json: https://github.com/tjvantoll/nativescript-photos-near-me/blob/6a201b05e91687618670a79e0a56ababc71572d7/package.json.
Any idea what might be up? I’m not actually using zones explicitly in my app, so I’m very curious why I’m getting this app here but not in new NativeScript Angular apps I start from scratch.
Any help would be appreciated.
So as soon as I posted this I figured this out. The problem was an innocuous looking call to the Mapbox plugin’s unhide() method.
I assumed “map” was referring to some RxJS or Array value, when it was actually referring to an actual map. Who knew?

Google Notifications fail sometimes with LinkageError, but work other times

I am using Azure Notification Hubs to send a notification to my Xamarin Forms app.
Sometimes (normally works the first time, then fails the second time) I am getting a Linker Error that the setVisibility method cannot be found.
java.lang.NoSuchMethodError: no method with name='setVisibility' signature='(I)Landroid/app/Notification$Builder;' in class Landroid/app/Notification$Builder;
I am at a loss as to what could be causing this, especially given that it finds the setVisibility method about 50% of the time.
This seems to be reproducable on a KitKat phone (API Level 19)
Update:
What is interesting is that if I include the NotificationCompat.Builder from the NotificationCompat, but do not use it the problem seems to go away.
The reason why this happens is because this was introduced in API 21. In the Android documentation you can see in the top right corner of this method of when this was introduced:
https://developer.android.com/reference/android/app/Notification.Builder.html#setVisibility(int)
Added in API level 21
Thus if you used this method on anything < API 21, it would crash because it does not exist. This is where you should be using NotificationCompat.Builder instead inside the Support.v4 library:
https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html

JS SDK not returning full object, only abbreviation

I'm upgrading from JS SDK 1.5 to latest.
With SDK 1.5 and earlier I could pass the full Parse Object from one CommonJS controller via the args variable.
[DEBUG] : Found CLUB: {"ACL":{"*":{"read":true},"15QSQgv93Z":{"read":true,"write":true}},"Address":"Atlanta, GA","ApprovalRequired":true,"MemberCount":1,"Name":"The Club Name","Public":true,"createdAt":"2016-02-11T22:01:29.361Z","updatedAt":"2016-02-11T22:01:31.796Z","objectId":"fqMZicTJbK"}
But after upgrading (no code changes) I'm only seeing this much
[DEBUG] : ARGS:{"club":{"_objCount":14,"className":"Club","id":"uPB7v2sb7G"}}
undefined is not a function (evaluating 'args.club.get(\"Name\")')
As you can see from the source code I am certainly getting the full ParseObject but it's not being received on the other end. Is it being reconstructed or something? I am not familiar with advanced JS.
Source code is here: https://gist.github.com/nitrag/183c2cc15921ab7447f2#file-club_list-js-L30
Thanks for looking

Resources