I'm using CloudKit to store my data but now I have to close the app every time something changed. With #FetchRequest this should be automatic, shouldn't it?
#FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Exercise.createdAt, ascending: true)],
animation: .default)
private var exercises: FetchedResults<Exercise>
Make sure your have enabled Push and remote notifications per the Apple Documentation
Project Settings > Signing and Capabilities
Sync CoreData with CloudKit using
try? persistentContainer.viewContext.setQueryGenerationFrom(.current)
Related
I am facing an issue while patching the credentials of a data set.
Our application is using the service principal to upload PowerBI reports to the respective PowerBI workspace. Most of the report is using Web Api sources, so we are patching the data source credentials using the below code, and it is working as expected.
//Create UpdateDatasourceRequest to update datasource credentials
var credentials = new AnonymousCredentials();
var credentialDetails = new CredentialDetails(credentials, PrivacyLevel.None, EncryptedConnection.NotEncrypted);
UpdateDatasourceRequest req = new UpdateDatasourceRequest(credentialDetails);
//Execute Patch command to update datasource credentials
await client.Gateways.UpdateDatasourceAsync((Guid)gatewayId, (Guid)datasourceId, req, cancellationToken);
We recently created a Power BI report with data flow as a data source (please note that the data flow is not created by the service principal), and when we tried to refresh the dataset after publishing the report to workspace, it threw an error: "Some of the data sources have missing credentials."
The credentials configuration is currently displayed in Power BI as follows:
After going through the following tutorial, I used the code below to set the credentials.
https://learn.microsoft.com/en-us/power-bi/developer/embedded/configure-credentials?tabs=sdk3
var gateway = pbiClient.Gateways.GetGatewayById(datasource.GatewayId);
var credentialsEncryptor = new AsymmetricKeyEncryptor(gateway.publicKey);
var credentialDetails = new CredentialDetails(
credentials,
PrivacyLevel.Private,
EncryptedConnection.Encrypted,
credentialsEncryptor);
However, because all of the data is in the cloud (Azure), obtaining the public key from the gateway is impossible.
I also tried the following code without encrypting the details, but it did not work. I received a Bad Request error and am pasting the exact error also.
var delta = new UpdateDatasourceRequest
{
CredentialDetails = new CredentialDetails
{
CredentialType = "OAuth2",
Credentials = "{\"credentialData\":[{\"name\":\"accessToken\", \"value\":\""+ result.AccessToken + "\"}]}",
EncryptedConnection = "Encrypted",
EncryptionAlgorithm = "None",
PrivacyLevel = "None"
}
};
await client.Gateways.UpdateDatasourceAsync((Guid)gatewayId, (Guid)datasourceId, delta, cancellationToken);
{"error":{"code":"DM_GWPipeline_Gateway_InvalidConnectionCredentials","pbi.error":{"code":"DM_GWPipeline_Gateway_InvalidConnectionCredentials","parameters":{},"details":[{"code":"DM_ErrorDetailNameCode_UnderlyingErrorCode","detail":{"type":1,"value":"-2147467259"}},{"code":"DM_ErrorDetailNameCode_UnderlyingErrorMessage","detail":{"type":1,"value":"The credentials provided for the PowerBI source are invalid. (Source at PowerBI.)"}},{"code":"DM_ErrorDetailNameCode_UnderlyingHResult","detail":{"type":1,"value":"-2147467259"}},{"code":"Microsoft.Data.Mashup.CredentialError.DataSourceKind","detail":{"type":1,"value":"PowerBI"}},{"code":"Microsoft.Data.Mashup.CredentialError.DataSourceOriginKind","detail":{"type":1,"value":"Web"}},{"code":"Microsoft.Data.Mashup.CredentialError.DataSourceOriginPath","detail":{"type":1,"value":"https://api.powerbi.com/powerbi/globalservice/v201606/clusterdetails"}},{"code":"Microsoft.Data.Mashup.CredentialError.DataSourcePath","detail":{"type":1,"value":"PowerBI"}},{"code":"Microsoft.Data.Mashup.CredentialError.Reason","detail":{"type":1,"value":"AccessForbidden"}},{"code":"Microsoft.Data.Mashup.MashupSecurityException.DataSources","detail":{"type":1,"value":"[{"kind":"PowerBI","path":"PowerBI"}]"}},{"code":"Microsoft.Data.Mashup.MashupSecurityException.Reason","detail":{"type":1,"value":"AccessForbidden"}}],"exceptionCulprit":1}}}
I'm missing something; any suggestions you have would be greatly appreciated.
Thanks in advance.
You can skip that bit for cloud data sources:
If you're using cloud data sources, don't follow the next steps in
this section. Call Update Datasource to set the credentials by using
the gateway ID and data source ID that you obtained in step 1.
https://learn.microsoft.com/en-us/power-bi/developer/embedded/configure-credentials?tabs=sdk3
I want to create/upload NFTs using metaplex on button click. I have the metadata json file an the nft artwork in a folder. They have to be uploaded to candy machine in a button click. Please help me out.
The Best Way to do this is using the Metaplex/js SDK because in Candy Machine the metadata is stored on-chain in an account and the mint Happens in Random order So it does not guarantee you that the user pressing the button is going to get the exact same NFT. So i would suggest you use the JS SDK it contains a function called create which can mint an NFT on-demand provided the metadata beforehand.
const { nft } = await metaplex
.nfts()
.create({
uri: "https://arweave.net/123",
name: "My NFT",
sellerFeeBasisPoints: 500; // Represents 5.00%.
})
.run();
We are developing an app in ionic3 which use PouchDB and CouchDB. We would like to launch on mid February but we are worry if the database grow too much I make run out of memory in device.
To test we'd like to insert thousands records and check database size.. here we have the problem. We can't find out how get local db size.
I was diving in PouchDB documentation and I only found how to get info about remote database size but not local. I think remote size needs not to be equal than local. Anyone have an idea?
Thanks
I found a partial solution, it is partial because it only works in android, chrome and firefox but not in ios and safari. I get used and available storage with this
calculaEspacio(){
let nav: any = navigator;
nav.storage.estimate().then((obj)=>{
this.usado=Math.round(((obj.usage/1048576)*100))/100;
this.total = Math.round(((obj.quota/1048576)*100))/100;
})}
Anyone know equivalent for webkit?
Example
npm install pouchdb pouchdb-size
//index.js
var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-size'));
var db = new PouchDB('test');
db.installSizeWrapper();
db.info().then(function (resp) {
//resp will contain disk_size
})
pouchdb-size https://github.com/pouchdb/pouchdb-size
Build Status Dependency Status devDependency Status
Adds disk_size to info()'s output for your *down backed PouchDB's.
Tested with leveldown, sqldown, jsondown, locket and medeadown. When it can't determine the database size, it falls back to the default info() output.
Full informations here
If you're using Ionic 3, I guess you can use the SQLite Plugin to have unlimited data
I am trying to update the commerce catalog from external source. After the incremental update I need to have fresh data in Sitecore tree(data provider should return correct data instead of old(cached) ones). However, if I go to Sitecore right after the data import I can see only the old data till I click on "Refresh Catalog Cache" button in Sitecore Commerce menu.
I found the same info in the documentation for Sitecore Commerce Connect, however I can't find any example how to clean cache via code.
I found several types in "Sitecore.Commerce.Connect.CommerceServer.Caching" namespace. For example, CacheRefresh static class. It has RefreshCatalogCaches method which needs ICommerceServerContextManager contextManager as input parameter. If I create contextManager just using constructor new CommerceServerContextManager() and passing it to the method - it doesn't work(at least I still need to clean cache manually).
I would appreciate any advise/suggestion.
Thank you in advance.
You should do in your code same that happens on "Refresh Catalog Cache" button click:
CacheRefreshEvent eventX = new CacheRefreshEvent("catalogcache", "master", = ID.Null);
EventManager.QueueEvent<CacheRefreshEvent>(eventX, true, true);
For more details, look on Sitecore.Commerce.Connect.CommerceServer.Caching.RefreshCache, Sitecore.Commerce.Connect.CommerceServer implementation via reflector.
This is my code:
- (IBAction)aBackupSetup:(UIButton *)sender {
// check to see if this device is iCloud enabled; display message if not
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
NSLog(#"AppDelegate: iCloud access!");
} else {
NSLog(#"AppDelegate: No iCloud access (either you are using simulator or, if you are on your phone, you should check settings");
}
I'm trying to determine if iCloud is enabled on the device (iPad). When I run this code by tapping on a UIButton in my app, it logs "No iCloud access...". I have seen this code all over SO and the internet - why is it not working on my device? (iCloud IS enabled on the iPad).
Reasons why you'd always get a nil result here:
iCloud is not actually enabled (though you say it was, so that's not it this time)
iCloud is enabled on the device but "Documents & Data" is not. "iCloud" covers a lot of services, so just being enabled in general isn't enough. Without Documents & Data, apps can't save data in iCloud.
Your provisioning profile either doesn't include iCloud or is broken in such a way that it prevents iCloud from working. Provisioning profile requirements include:
You must enable iCloud for the app ID in the "Certificates, Identifiers & Profiles" section of the iOS dev center.
The app ID can't include a wildcard (*), it has to be a complete ID.
Your app ID in Xcode must match the one from the previous step exactly.
You must generate a provisioning profile after doing the above so that you have a profile that reflects the iCloud entitlement. If you had an old provisioning profile for this app that didn't include iCloud, you must delete it and replace it with a new one.
If you get any of these steps wrong, checking the URL will simply return nil. There's no error condition, but since iCloud access is not enabled there's no URL either.
For iOS 6 and up you're better off checking for iCloud availability using
id ubiquityToken = [[NSFileManager defaultManager] ubiquityIdentityToken];
That's a lot faster. Looking up the URL can involve network connections, but this method returns immediately. You'll still need the URL to read/write data in iCloud, but if you just want to check availability, use this method.