Cant add new contact using expo-contacts in react native - android

I am doing a contacts app using expo-contacts, I can see contacts but the problem comes when I need to add one.
This is the code I am using, the thing is that in some phones works and in other doesn't. Just to let you know, the permissions to write and read are already attached in app.json.
<Button
title="Guardar"
onPress={async () => {
const contact = {
[Contacts.Fields.FirstName]: "Test",
[Contacts.Fields.LastName]: "McTest",
[Contacts.Fields.PhoneNumbers]: [
{
number: "(123) 456-7890",
isPrimary: true,
digits: "1234567890",
countryCode: "PA",
id: "1",
label: "main",
},
],
[Contacts.Fields.Emails]: [
{
email: "test#gmail.com",
isPrimary: true,
id: "2",
label: "main",
},
],
};
await Contacts.addContactAsync(contact)
.then((contactId) => {
alert("Se creó exitosamente");
})
.catch((err) => {
alert(err);
console.log(err);
});
}}
The error I am getting is this: Error: insert into content://com.android.contacts/data returned no result.
To finish its important to say that I am using apk already built and not doing in debugging mode in expo.
I will appreciate your answers.

Solved: it was how i organiced data structure to push contact details.

[Contacts.Fields.PhoneNumbers]: [
{
number: "(123) 456-7890",
isPrimary: true,
digits: "1234567890",
countryCode: "PA",
id: "1",
label: "main",
},
]
Changing label from 'main' to 'mobile' worked for me.

Related

accounts.register returning isRegistered: true when "finalizeRegistration": false in Android alone

I hope someone can please help with this as I do not seem able to figure out on my own.
Here is our gigyaSdkConfiguration.json:
{
"apiKey": "API_KEY_HERE",
"apiDomain": "eu1.gigya.com",
"accountCacheTime": 60,
"account": {
"cacheTime": 1,
"include": [
"data",
"profile",
"emails"
],
"extraProfileFields": [
"locale",
"phones"
]
},
"sessionVerificationInterval": 0
}
We are moving from a single step registration to a three steps one.
What we currently have is this:
await _gigya.register(
options.email,
options.password,
params: {
"profile": ...,
"data": ...data,
"preferences": ...preferences,
"subscriptions": ...subscriptions,
"finalizeRegistration": true,
});
moving on to:
final Map<String, dynamic>? initRegistrationResponse = await
_gigya.send("accounts.initRegistration",{});
await _gigya.register(
options.email,
options.password,
params: {
"profile": ...,
"data": ...data,
"preferences": ...preferences,
"subscriptions": ...subscriptions,
"finalizeRegistration": false,
"regToken": initRegistrationResponse?['regToken'].toString(),
});
which works correctly on iOs, as it returns something like:
{
"errorCode": 206001,
"errorMessage": "Account Pending Registration",
"statusCode": 206,
"statusReason": "Partial Content"
}
For some reason the same flow in Android will return a success such as:
{
errorCode: 0,
apiVersion: 2,
statusCode: 200,
statusReason: OK,
isActive: true,
isRegistered: true,
isVerified: false
}
the expected response should be the same as the one from iOs, so as to be able to then call accounts.finalizeRegistration and effectively change the value of "isRegistered" to true.
Any idea why this is happening?
The sdk is correctly configured, I am currently using ^0.2.1, but have also tested several previous ones, and we have been using a dozen other endpoints for months without a single issue.

Flutter Notifications: Display WhatsApp like notification

I am trying to display notifications in my flutter app using awesome_notifications package (https://pub.dev/packages/awesome_notifications) . Below is my code.
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: UniqueKey().hashCode,
groupKey: message.data["senderUid"],
channelKey: 'basic_channel',
title: message.data["title"],
body: message.data["body"],
summary: message.data["body"], // Anything you want here
notificationLayout: NotificationLayout.Messaging,
),
);
Below is my Json data
"message": {
"token": recieverFcm,
"data": {
"title": senderName,
"body": message,
"chatRoomId": chatRoomId,
"sender_profile_pic": senderProfilePic,
"senderUid": senderUid,
"click_action": "OPEN_CHAT_ROOM"
},
"android": {
"priority": "high"
},
"apns": {
"payload": {
"aps": {
"category": "OPEN_CHAT_ROOM"
}
}
}
}
This works fine and I get notifications like below.
In here it is displaying the first letter of the sender's name as the icon/profile picture. Instead, I would like to display the real photo of the sender. This profile photo is already being sent by the JSON code.
How can I do this?

Messaging extension on query result select item is not invoked on Android/IOS Teams app

I have made an app for Teams that I want to use to display an adaptive card to the user when they pick an item from the list of search results. In order for this to happen, I need to trigger some code after the user selects a result. This works as expected from the Teams client, as well as in the browser, but from native mobile Teams app, the code is not triggered when selecting an item from the list of results.
const preview = CardFactory.heroCard( obj.package.name );
preview.content.tap = { type: 'invoke', value: { description: obj.package.description } };
The following pictures show the app working in a browser on the computer:
The list of results from the browser on PC
The expected adaptive card showing correctly on browser
And this is how it looks from the mobile perspective:
The list of results from mobile app
The result of selecting the same item from the list
The code used to display this has not been modified, except providing a bot to host it, and was found from Microsoft's bot samples on GitHub:
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/typescript_nodejs/50.teams-messaging-extensions-search
The code in question looks as follows:
export class TeamsMessagingExtensionsSearchBot extends TeamsActivityHandler {
public async handleTeamsMessagingExtensionQuery( context: TurnContext, query: any ): Promise<any> {
const searchQuery = query.parameters[ 0 ].value;
const response = await axios.get( `http://registry.npmjs.com/-/v1/search?${ querystring.stringify( { text: searchQuery, size: 8 } ) }` );
const attachments = [];
response.data.objects.forEach( ( obj: any ) => {
const heroCard = CardFactory.heroCard( obj.package.name );
const preview = CardFactory.heroCard( obj.package.name );
preview.content.tap = { type: 'invoke', value: { description: obj.package.description } };
const attachment = { ...heroCard, preview };
attachments.push( attachment );
} );
return {
composeExtension: {
attachmentLayout: 'list',
attachments,
type: 'result'
}
};
}
public async handleTeamsMessagingExtensionSelectItem( context: TurnContext, obj: any ): Promise<any> {
return {
composeExtension: {
attachmentLayout: 'list',
attachments: [ CardFactory.thumbnailCard( obj.description ) ],
type: 'result'
}
};
}
}
Is this expected?
Thanks
Edit: Adding the manifest JSON used here:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "1.0.0",
"id": "9211fa66-f930-414d-861a-40f18f7f1490",
"packageName": "com.teams.sample.teamsmessagingextensionssearch",
"developer": {
"name": "teamsStartNewThreadInChannel",
"websiteUrl": "https://www.microsoft.com",
"privacyUrl": "https://www.teams.com/privacy",
"termsOfUseUrl": "https://www.teams.com/termsofuser"
},
"icons": {
"outline": "icon-outline.png",
"color": "icon-color.png"
},
"name": {
"short": "Search Messaging Extension",
"full": "Microsoft Teams Search Based Messaging Extension"
},
"description": {
"short": "Sample demonstrating a Search Based Messaging Extension",
"full": "Sample Search Messaging Extension built with the Bot Builder SDK"
},
"accentColor": "#FFFFFF",
"bots": [
{
"botId": "9211fa66-f930-414d-861a-40f18f7f1490",
"scopes": [
"personal",
"groupchat",
"team"
],
"supportsFiles": false,
"isNotificationOnly": false
}
],
"composeExtensions": [
{
"botId": "9211fa66-f930-414d-861a-40f18f7f1490",
"canUpdateConfiguration": true,
"commands": [
{
"id": "searchQuery",
"context": [
"compose",
"commandBox"
],
"description": "Test command to run query",
"title": "Search",
"type": "query",
"parameters": [
{
"name": "searchQuery",
"title": "Search Query",
"description": "Your search query",
"inputType": "text"
}
]
}
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": []
}
We are able to re-pro the issue at our end. Raised a bug.We are tracking the bug internally, we don't have ETA to share when it will be fixed. Will update once it is fixed.

AdaptiveCard button with Action.submit not working on android device

I have developed a bot that has an invite card when the user did not add the bot yet, it will return the following JSON to render the AdaptiveCard:
{
body: [
{
text: translations['MsTeams::AdaptiveCardBodyLooksLikeTryToUseApp'],
wrap: true,
type: 'TextBlock',
},
{
text: translations['MsTeams::AdaptiveCardBodyNeedToInviteApp'],
wrap: true,
type: 'TextBlock',
},
],
actions: [
{
data: {
actionId: 'INSTALL_BOT_SUBMIT',
cancel: true,
},
title: translations['MsTeams::Cancel'],
type: 'Action.Submit',
},
{
data: {
msteams: {
justInTimeInstall: true,
},
actionId: 'INSTALL_BOT_SUBMIT',
},
title: translations['MsTeams::Invite'],
type: 'Action.Submit',
},
],
type: 'AdaptiveCard',
version: '1.0',
}
And it's working fine on desktop, browser, and iOS devices, but not working on Android devices.
Here is the device & app info:
Android device version: 8.0.0
MS teams app version: 1416/1.0.0.2021010802
This is just an idea, but I see lots of hanging commas (e.g. type: 'TextBlock',). It might be that the Android parser is stricter on this - try remove them and test again.

Does anyone know how to fetch data from json in react native?

I am new in react native and I need to take information from JSON file asynchronously on change text in input field.
JSON:
{ "meta": {
"code": 200,
"api_version": "2.0.1.6.0",
"issue_date": "20160620"
},
"result": {
"total": 4,
"items": [{
"purpose_name": "Торгово-развлекательный комплекс",
"name": "Asia Park, торгово-развлекательный комплекс",
"full_name": "Алматы, Asia Park, торгово-развлекательный комплекс",
"id": "9430047374983999",
"building_name": "Asia Park, торгово-развлекательный комплекс",
"address_name": "Райымбека проспект, 514а / Саина, 516",
"type": "building"
}]
}
}
If it is a local JSON file you can just use require:
const data = require('./data.json');
console.log( data.result.items[0].purpose_name );
If it is a remote API request try fetch:
fetch('https://example.com/data.json')
.then(response => response.json())
.then(data => console.log( data.result.items[0].purpose_name ))
.catch(error => console.log(error));
If this file is local you may simply require it, it will get parsed automatically. If it is on some server you need to use the Fetch API.

Categories

Resources