React native background actions intent app - react-native

I am using react native background actions but as i am getting a notification when i click on the notification. I is opening gallery in the app by default. I want to open my app. Not able to get how can i open app on click on the notification.
const options = {
taskName: 'Downloading',
taskTitle: 'ExampleTask title',
taskDesc: 'ExampleTask description',
taskIcon: {
name: 'ic_launcher',
type: 'mipmap',
},
color: '#ff00ff',
linkingURI: 'yourSchemeHere://chat/jane', // See Deep Linking for more info
parameters: {
delay: 15000,
},
};
Not getting how to use linking to open my app instead of the gallery using intent filter or something else.

In order to open the respective app when the user clicks on the notification of react native background action service.
Take these two steps -
Add intent filter on AndroidManifest.xml located at android/app/src/main. Under application activity tag.
Also, verify this line "android:launchMode="singleTask"" should be
there in activity tag. if not then please add it
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="technomizeEMS" /> // Your custom scheme name then in second step we'll add this on linkingURI
</intent-filter>
Add linkingUri in the configuration option of the start method. (The important takeaway for linkingURI is to add the same name as added on intent-filter
in data tag android:scheme in AndroidManifest.xml and also append :// )
const options = {
taskName: 'Task Name',
taskTitle: 'Task Title',
taskDesc: 'Task Description',
taskIcon: {
name: 'ic_launcher',
type: 'mipmap',
},
color: '#ff00ff',
// The important take away for linkingURI is to add same name as added on intent-filter
// in data tag android:scheme in AndroidManifest.xml and also append ://
linkingURI: 'technomizeEMS://', // See Deep Linking for more info
parameters: {
delay: 1000,
},
};
await BackgroundService.start(this.veryIntensiveTask, options);
For more detail you can refer here
https://github.com/Rapsssito/react-native-background-actions#deep-linking
Hope it will help you or somebody else. Thanks!
Happy Coding :-)

Related

React-Admin doesn't show column data in List component

I don't seem to be able to understand why data is missing. Here is my field:
<ReferenceField source="imageId" reference="files">
<TextField source="urlPath" />
</ReferenceField>
Here is what the main model papers is returning:
brandId: "b3dc4246-3adf-4f4e-9f81-294f23d24977"
brandModelId: "2819360d-2e6e-48e4-88a3-823a03177a7c"
colorId: "98031f74-a83f-4389-b9d6-bab959ff8a0e"
gsm: 200
id: "058cc13d-1255-4d9b-9ccf-e087ddb3935d"
imageId: "1bc99717-f60c-485e-989a-5d1726501b8d"
originalSize: "A4"
paperMaterialId: "5afd0d7c-5ace-49e3-a538-894ce288fe71"
paperSurfaceId: null
price: 12
ref: "44202129"
storeId: "2f7567ad-fa62-4bda-851b-89b8c39a189e"
Here is what the related model files is returning:
id: "1bc99717-f60c-485e-989a-5d1726501b8d"
originalFileName: "palette1.2.png"
type: "undefined"
urlPath: "asdf/101d7c68-9bf4-4d55-bbb5-818f62c480a3-palette1.2.png"
but here is my screenshot with missing data:
Note that the Store related field works, which has the exact same code:
<ReferenceField source="storeId" reference="stores">
<TextField source="name" />
</ReferenceField>
Also, here is my getMany dataProvider:
getMany: (resource, params) => {
const query = {
filter: JSON.stringify({ id: params.ids }),
};
const url = `${API_URL_LOCAL}/${resource}?${stringify(query)}`;
return request(url, 'get', {}, {}).then(({ data }) => ({
data,
}));
},
Any help is welcome.
In cases where you have some reference fields working, and others not, and no error is logged in console, this probably means that the non-working reference resource wasn't declared as Admin child with <Resource name="files" .../>.
From react-admin docs:
Note: You must add a <Resource> for the reference resource -
react-admin needs it to fetch the reference data. You can omit the
list prop in this reference if you want to hide it in the sidebar
menu.
https://marmelab.com/react-admin/Fields.html#referencefield
If none reference resource is working, and the resources has been properly declared, the error will probably rely on your data provider. Log the responses for getMany requests and see if it match the expected format and if it contains any data and not an empty array:
getMany { data: {Record[]}, validUntil?: {Date} }
A {Record} is an object literal with at least an id property, e.g. {
id: 123, title: "hello, world" }.
The validUntil field in the response is optional. It enables the
Application cache, a client-side optimization to speed up rendering
and reduce network traffic
https://marmelab.com/react-admin/DataProviders.html#writing-your-own-data-provider

Error: 400: Your project does not own Dynamic Links domain

I'm using react-native-firebase to create dynamic links, when I create standard link everything works fine, but when I'm creating short link, it gives an error: "Error: 400: Your project does not own Dynamic Links domain". Any ideas how is possible to fix that?
UPDATE: problem occurs only in Android, in IOS works fine
Code for the creating short dynamic link:
onClickShare= () => {
const link =
new firebase.links.DynamicLink(redirectLink , Config.FIREBASE_CONFIG.dynamicLink)
.android.setPackageName(Config.ANDROID_PACKAGE_NAME)
.ios.setBundleId(Config.IOS_BUNDLE_ID)
.ios.setAppStoreId(Config.IOS_APP_STORE_ID)
.social.setDescriptionText(description)
.social.setTitle(this.props.event.title)
firebase.links()
.createShortDynamicLink(link, 'SHORT')
.then((url) => {
Share.share({
message: _('shareLinkMessage') + " " + url,
title: _('shareLinkTitle'),
}, {
// Android only:
dialogTitle: _('shareLinkAndroid'),
})
})
If you get such error, update your google-services.json file!
In my case (using Flutter), I was getting this error because of incorrect "uriPrefix" parameter while in DynamicLinkParameters object params:
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: your_page_link, //<-- this should be same as in your Firebase project
link: Uri.parse(....),
androidParameters: AndroidParameters(
....
),
iosParameters: IOSParameters(
....
),
);
Please make sure if you have uriPrefix value set properly.
when you get this error that means you did not add the dynamic link domain as a formate of the firebase link.
you must follow this formate:
<app_name.page.link>
In android/app/src/main/AndroidManifest.xml add within the activity:
<!-- Deep linking -->
<meta-data android:name='flutter _deeplinking_enabled'
android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="<app_name.page.link>" />
<data android:scheme="https" />
</intent-filter>
and added at the same with that formate <app_name.page.link> in dynamic link code.
Try this method,
import dynamicLinks from '#react-native-firebase/dynamic-links';
async function generateLink() {
const link = await dynamicLinks().buildLink({
link: 'valid domain url',
domainUriPrefix: 'valid domain url',
analytics: {
content: 'your data',
},
});
console.log(link)
}
You might not have done npm install if your google-services.json is already updated

Share to React-Native

I am trying to have apps on the android device to share to my react-native app. However, I can't find any documentation which can help me so I was wondering if there any way to share content from other apps to my app?
Clarification:
I am trying to add my app to this list
You need Allowing Other Apps to Start Your Activity. reference here.
<intent-filter android:label="Share here!">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
As you may notice, This Witchcraft will show your app on the Sharing list.
In order to handle the burden, place the next snippet in your component. Any component.
componentDidMount() {
Linking.getInitialURL().then((url) => {
console.log('Initial url is: ' + url);
}).catch(err => console.error('An error occurred', err));
}
This charm is called Linking. Documentation found here

Alfresco custom action permission

I have done a custom action. I can see the action in documentary library but i canot see it on faceted search result page.
<action id="custom-action" type="javascript" label="actions.custom.action">
<param name="function">onCustomActionlick</param>
</action>
So I went in the aikau-1.0.8.1.jar\META-INF\js\aikau\1.0.8.1\alfresco\renderers\_ActionsMixin.js file.
I see that we do a test to determine if action is allowed in this file :
if (this.filterActions === false || AlfArray.arrayContains(this.allowedActions, action.id))
On firebug i see that my costum action is not in the allowedActions object. My question is why ?
I think that actions wich have not permission are always allowed to all users. Am I right ?
What can i do to allow this action et make it visible on faceted search result page?
Thank you in advance.
You need to write an extension module which is described here: https://forums.alfresco.com/comment/159331#comment-159331.
In the JavaScript code you need to get the widget id of MERGED_ACTIONS and add your customAction to the array of allowdActions and define it in CustomActions.
This is the Aikau code from the link, probably it has been updated in the newer Alfresco version. So you need to extend this within your extension module.
You can probably just use org\alfresco\share\pages\faceted-search as your <sourcePackageRoot> in the module.
widgets: [{
id: "MERGED_ACTIONS",
name: "alfresco/renderers/Actions",
config: {
filterActions: true,
mergeActions: true,
allowedActions: ["folder-manage-rules", "folder-download", "folder-view-details", "CUSTOM3"],
customActions: [{
id: "CUSTOM3",
label: "Custom Action 3",
icon: "document-delete",
index: "10",
publishTopic: "DELETE_ACTION_TOPIC",
type: "javascript"
}],
widgetsForActions: [{
name: "alfresco/renderers/actions/ManageAspects"
}]
}
}]
The Document Library (at least up until Alfresco Share 5.1) is built with YUI, whereas the search page is built using Aikau. At the time of writing there is not yet parity of action handling between the search page and the Document Library, and the process of adding actions is very different.
In order to get your custom action to display in the faceted search page you'll need to do a couple of things:
Extend the search page to update the configuration for the "alfresco/search/AlfSearchResult" (it has the id "FCTSRCH_SEARCH_RESULT") to add your custom actions to the "additionalDocumentAndFolderActions" array (see http://dev.alfresco.com/resource/docs/aikau-jsdoc/AlfSearchResult.html)
Your custom action will publish a topic, so you need to create a new service to subscribe to that topic to perform the action. You will need to further extend the faceted search page so that your service is included on the page.
I'm paraphrasing from our latest blog the method we've used for this.
Our use case was we had existing actions in the document library view we didn't want to have to recreate, with standard configuration xml.
The first step is to create a Share Extension Module to add a Javascript controller in web-extensions/site-data/extensions/example.xml:
<extension>
<modules>
<module>
<id>Example Service</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.pages.faceted-search</targetPackageRoot>
<sourcePackageRoot>com.parashift.example</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
This will load some extra javascript, allowing you to adjust the widget config.
Create a file in web-extension/site-webscripts/com/parashift/example/faceted-search.get.js (or whatever package name you've used in sourcePackageRoot), add in a file called faceted-search.get.js with the following contents:
var searchResultPage = widgetUtils.findObject(model.jsonModel.widgets, "id", "FCTSRCH_SEARCH_RESULT");
if(searchResultPage != null) {
searchResultPage.config = {
enableContextMenu : false,
mergeActions : true,
additionalDocumentAndFolderActions : ["example-action"]
}
}
model.jsonModel.widgets.push({
id: "EXAMPLE_LISTENER",
name: "parashift/action/example"
});
This will:
Add example-action to the list of actions in the search results. This should already be a configured action in some share-config.xml file.
Add a new listener widget for you to listen to when the action button is clicked.
Add a file for your listener widget: META-INF/parashift/action/example.js
define(["dojo/_base/declare",
"dijit/_WidgetBase",
"alfresco/core/Core"
],
function(declare, _Widget, Core) {
return declare([_Widget, Core], {
postCreate: function () {
this.alfSubscribe("ALF_SINGLE_DOCUMENT_ACTION_REQUEST", lang.hitch(this, this._onPayloadReceive));
},
_onPayloadReceive: function (payload) {
if(payload.action.id == "example-action") {
this.alfLog("log", "Received action, handling accordingly");
.......
}
}
});
});
This code will listen for ALF_SINGLE_DOCUMENT_ACTION_REQUEST and execute the _onPayloadReceive function. In this function we filter to the example-action and execute any custom code.
The payload variable will include document and action objects. Using Debug Logging you can see what their shape is.
This is roughly equivalent to the old YUI method:
YAHOO.Bubbling.fire("registerAction", {
actionName: "onExampleAction",
fn: function(file) {
console.log("Received action, handling accordingly");
....
}
});

How to take a photo using Camera in Sencha App?

I am trying to take a picture using camera in Sencha Touch 2. Here i have one button 'Take a Picture', when i will press it, camera should start. As i am new to this sencha touch 2, i am unable to figure it out, how to do this?
For this i used the below code:
Sencha Fiddle Link
Please help me. I do not want to use Phone gap.
You have to add device folder of Sencha Library in root directory
and add below code in
Ext.require('Ext.device.Camera');
and use this code for capture image using camera
Ext.device.Camera.capture({
success: function(image) {
imageView.setSrc(image);
},
quality: 75,
width: 200,
height: 200,
destination: 'data'
});
If you want to use purely sencha, then you can check this code:
xtype: 'button',
handler: function(button, event) {
Ext.device.Camera.capture({
source: 'camera',
destination: 'data',
success: function(imagedata) {
var img = Ext.getCmp('theimage');
img.setSrc('data:image/jpeg;base64,' +imagedata);
},
failure: function() {
Ext.Msg.alert('Error', 'There was an error when acquiring the picture.');
},
scope: this
});
But if you want to use phonegap camera features, may be you have to change the code. As sencha is giving the default feature to handle the camera, i wish not to go with phonegap. Hope it will help..