Here SDK Crash any tip why? - here-api

With the Here SDK Navigate for Flutter. I'm seing this crash and no clue why it happens, I'm not using venues. Any tip?
Here's what I see in crashlytics
libsyXstem_kernel.dylib
__pthread_kill + 8
libsystem_pthread.dylib
pthread_kill + 268
libsystem_c.dylib
abort + 168
libsystem_malloc.dylib
_malloc_put + 550
libsystem_malloc.dylib
malloc_report + 64
libsystem_malloc.dylib
free + 300
arrow_right 6
heresdk
here_sdk_sdk_venue_threading_VenueThreads_get_type_id
libdispatch.dylib
_dispatch_client_callout + 20
libdispatch.dylib
_dispatch_root_queue_drain + 680
libdispatch.dylib
_dispatch_worker_thread2 + 164
libsystem_pthread.dylib
_pthread_wqthread + 228
libsystem_pthread.dylib

Please try with the below hellomap example.
import 'package:flutter/material.dart';
import 'package:here_sdk/core.dart';
import 'package:here_sdk/core.engine.dart';
import 'package:here_sdk/core.errors.dart';
import 'package:here_sdk/mapview.dart';
void main() async {
// Usually, you need to initialize the HERE SDK only once during the lifetime of an application.
_initializeHERESDK();
runApp(MyApp());
}
void _initializeHERESDK() async {
// Needs to be called before accessing SDKOptions to load necessary libraries.
SdkContext.init(IsolateOrigin.main);
// Set your credentials for the HERE SDK.
String accessKeyId = "YOUR_ACCESS_KEY_ID";
String accessKeySecret = "YOUR_ACCESS_KEY_SECRET";
SDKOptions sdkOptions = SDKOptions.withAccessKeySecret(accessKeyId, accessKeySecret);
try {
await SDKNativeEngine.makeSharedInstance(sdkOptions);
} on InstantiationException {
throw Exception("Failed to initialize the HERE SDK.");
}
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'HERE SDK for Flutter - Hello Map!',
home: HereMap(onMapCreated: _onMapCreated),
);
}
void _onMapCreated(HereMapController hereMapController) {
hereMapController.mapScene.loadSceneForMapScheme(MapScheme.normalDay, (MapError? error) {
if (error != null) {
print('Map scene not loaded. MapError: ${error.toString()}');
return;
}
const double distanceToEarthInMeters = 8000;
MapMeasure mapMeasureZoom = MapMeasure(MapMeasureKind.distance, distanceToEarthInMeters);
hereMapController.camera.lookAtPointWithMeasure(GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);
});
}
}
For complete example please check below link.
https://github.com/heremaps/here-sdk-examples/tree/master/examples/latest/navigate/flutter/hello_map_app

Related

Firebase cloud messaging notifications received but not popping up with capacitor/push-notifications

In my Angular 13 Ionic 6 app I'm using the capacitor/push-notifications with FireBase,
In my service:
import { EventEmitter, Injectable, Output } from '#angular/core';
import {ActionPerformed, PushNotifications, PushNotificationSchema, Token} from '#capacitor/push-notifications';
import { Capacitor } from '#capacitor/core';
import { Dialogs, DialogType } from '../Utilities/dialogs';
import { get, set, remove } from './storage.service';
import { BehaviorSubject } from 'rxjs';
import { App } from '#capacitor/app';
//https://devdactic.com/push-notifications-ionic-capacitor/
#Injectable({
providedIn: 'root'
})
export class FbNotificationsService {
onFCMTokenChanged: BehaviorSubject<string> = new BehaviorSubject('');
tokenProcessed: boolean = false;
constructor(private dialogs: Dialogs) {
}
initPush() {
if (Capacitor.getPlatform() !== 'web') {
this.registerPush()
} else {
console.log('Web platform detected');
this.onFCMTokenChanged.next('web-platform');
}
}
private registerPush() {
PushNotifications.requestPermissions().then((permission) => {
if (permission.receive === 'granted') {
// Register with Apple / Google to receive push via APNS/FCM
console.log('FB Permission granted');
PushNotifications.register(); //Registers app to receive notifications
} else {
// No permission for push granted by user on iOS
console.log('FB NO permissions granted');
}
});
PushNotifications.addListener(
'registration',
(token: Token) => {
if ((token)&&(!this.tokenProcessed)) {
this.tokenProcessed = true;
console.log('My token: ' + JSON.stringify(token));
this.onFCMTokenChanged.next(token.value);
set('device-token', token.value);
}
});
PushNotifications.addListener('registrationError', (error: any) => {
console.log('Registration Error: ' + JSON.stringify(error));
this.dialogs.dialogClose('Network Error','The network signal is not sufficient at this time. Please improve connection and try again');
App.exitApp();
});
PushNotifications.addListener(
'pushNotificationReceived',
async (notification: PushNotificationSchema) => {
console.log('Push received: ' + JSON.stringify(notification));
alert('Push received: ' + JSON.stringify(notification));
//What to do next. Notification received on the device.
}
);
PushNotifications.addListener(
'pushNotificationActionPerformed',
async (notification: ActionPerformed) => {
const data = notification.notification.data;
console.log('Action performed: ' + JSON.stringify(notification.notification));
alert('Push action performed: ' + JSON.stringify(notification));
//What to do next. data holds all payload fields of the notification object
}
);
}
}
The basic guide I followed is here.
When I send a test message from the Firebase console, the alert statement I placed is poping up, meaning, the message is received by the app:
alert('Push received: ' + JSON.stringify(notification)); //WORKING
HOWEVER, there is no notification message popping up by the OS for the user to see. I do get notifications all the time from Whatapp, Emails, etc, and the "Do not disturb" setting is turned off.
This is experienced with TWO Android devices: Xiaomi Rednote 8 and Samsung Galaxy A32.
Am I missing something?
I had a similar problem before, maybe the following information could help you:
When your Android app is in the foreground, PushNotifications won't appear on the screen.
If you absolutely want a visual display of the notification, you can create a local notification when the push notification is received.

How to build a spring-kafka consumer to consume messages produced by KafkaJS producer

I know in KafkaJS we can consume message with the following code
const run = async () => {
await kafkaClient.consumer.subscribe({ topic: 'mytopic', fromBeginning: true })
await kafkaClient.consumer.run({
eachBatchAutoResolve: false,
eachBatch: async ({ batch, resolveOffset, heartbeat, isRunning, isStale }) => {
for (let message of batch.messages) {
if (!isRunning() || isStale()) break
processMessage(message)
resolveOffset(message.offset)
}
},
})
}
And the message format is like this
{
magicByte: 2,
attributes: 0,
timestamp: '540669',
offset: '601953',
key: <Buffer 39 63 37 23>,
value: <Buffer 7b 65 32 65 37 38 ... 555 more bytes>,
headers: {
'myheader': <Buffer 61 6f>,
},
‧‧‧‧‧‧
}
But now I'm using KafkaListener in spring boot as consumer.
#org.springframework.kafka.annotation.KafkaListener(
topics = "mykafkatopic",
groupId = "groupId"
)
void listener(WhatTypeShouldThisBe data){
}
}
In JS, the type of the message is object, so I'm confused about what type of object should be used in the java listener function to receive the message?
And the messages produced by KafkaJS are serialized, how to deal with the serialization in java consumer?
Update1:
Should I define a class like this
public class messageFormat{
int magicBytes;
‧‧‧
byte[] key;
selfDefinedHeaderClass header;
}
And then modify the ConsumerFactory function to this
public ConsumerFactory<String, messageFormat> consumerFactory() {
// ...
return new DefaultKafkaConsumerFactory<>(
props,
new StringDeserializer(),
new JsonDeserializer<>(messageFormat.class));
}
You need to define a Java class with the fields from the JSON and use the JsonDeserializer in the consumer configuration, configured to deserialize the JSON and create an instance of that class.
https://docs.spring.io/spring-kafka/docs/current/reference/html/#json-serde

flutter navigation :: '!_debugLocked': is not true

So in my app I'm using a navigation service here :
class NavigationService {
GlobalKey<NavigatorState> _navigationKey = GlobalKey<NavigatorState>();
GlobalKey<NavigatorState> get navigationKey => _navigationKey;
void pop() {
return _navigationKey.currentState.pop();
}
Future<dynamic> navigateTo(String routeName, {dynamic arguments}) {
return _navigationKey.currentState
.pushNamed(routeName, arguments: arguments);
}
}
and in order to toggle between login in and sign up I user this method :
void navigateToSignup(){
_navigationService.navigateTo(SignUpViewRoute);
}
and in the button :
onPressed: (){
model.navigateToSignup();
},
when I run and try to click the button I get this error
'package:flutter/src/widgets/navigator.dart':
Failed assertion: line 4028 pos 12: '!_debugLocked': is not true.
I've read different solutions but not sure where to exactly do It in my app

Flutter: GeoFire library search queryAtLocation not working

I am testing the Flutter Library https://github.com/bramvbilsen/Flutter-GeoFire.
When I load the example/main.dart file from the library (pointing it to my Firebase) the setLocation() method works (the entry writes to my FirebaseDB) but not the read location or query At Location methods.
// Methods from library example not working..
void getAndPrintLocation() {
geofire.getLocation("Mechelen", new LocationCallBack(
(String key, List<double> location) {
print("Successfully received location!");
print(key + ": " + location.toString());
},
(DatabaseError error) {
print("Error receiving location!");
print(error.toString());
}
));
}
void createQuery(List<double> location, double radius) {
this.query = geofire.queryAtLocation(location, radius);
print(this.query.toString());
}
The return message from queryAtLocaion
I/flutter (18068): GeoQuery
I/flutter (18068): --- Center: [51.0259, 4.4775]
I/flutter (18068): --- Radius: 450.0
What am I missing. I am simply trying to get the keys from the queryAtLocaion(location, radius)

Angular2 http get request with Observables and dynamic url params. How to?

Having this angular2 service taken from official docs with Observable, trying to modify to can pass on fly to the base heroesUrl dynamic parameters like app/heroes/{{country}} and use it like
getHeroes(country) {}
import { Injectable } from '#angular/core';
import { Http, Response } from '#angular/http';
import { Hero } from './hero';
import { Observable } from 'rxjs/Observable';
#Injectable()
export class HeroService {
constructor (private http: Http) {}
private heroesUrl = 'app/heroes'; // URL to web API
getHeroes (): Observable<Hero[]> {
return this.http.get(this.heroesUrl)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body.data || { };
}
private handleError (error: any) {
// In a real world app, we might use a remote logging infrastructure
// We'd also dig deeper into the error to get a better message
let errMsg = (error.message) ? error.message :
error.status ? `${error.status} - ${error.statusText}` : 'Server error';
console.error(errMsg); // log to console instead
return Observable.throw(errMsg);
}
}
How would I do that?
I think you just need to do following things if I understood your point,
getHeroes(country) {}
export class HeroService {
constructor (private http: Http) {}
private heroesUrl = 'app/heroes'; // URL to web API
getHeroes (country): Observable<Hero[]> { //<-----added parameter
return this.http.get(this.heroesUrl + '/' + country) //<-----changed
.map(this.extractData)
.catch(this.handleError);
}
...
...
}

Resources