InApp Provisioning - Apple Pay - c#

I am trying to implement InApp Provisioning - Apple Pay in Xamarin forms project
but I didn't find much resources that explain the steps clearly.
What is the correct setup?
How to test it, and what about env (sandbox or production) ?
Hope that I can find helpful answers
Thank you!
var canaddpass = PKAddPaymentPassViewController.CanAddPaymentPass;
if (canaddpass)
{
var config = new PKAddPaymentPassRequestConfiguration(PKEncryptionScheme.Ecc_V2);
var addPaymentPassVC = new PKAddPaymentPassViewController(config, this);
View.BackgroundColor = UIColor.White;
Title = "My Custom View Controller";
var btn = UIButton.FromType(UIButtonType.System);
btn.Frame = new CGRect(20, 200, 280, 44);
btn.SetTitle("Click Me", UIControlState.Normal);
btn.TouchUpInside += (sender, e) => {
//this.ShowViewController(addPaymentPassVC, (Foundation.NSObject)sender); This line will also work
this.PresentViewControllerAsync(addPaymentPassVC, true);
};
View.AddSubview(btn);
}
I tried the above code but I got this exception:
System.Exception: Could not initialize an instance of the type 'PassKit.PKAddPaymentPassViewController': the native 'initWithRequestConfiguration:delegate:' method returned nil

PKAddPaymentPassViewController, which requires the com.apple.developer.payment-pass-provisioning entitlement key for your app.
To add this key following steps:
Go to Identifier section in the developer portal:
Select your identifier and go to Aditional Capabilities, enable option like this:
Got to iOS project, add this key to Entitlements.plist file:
<key>com.apple.developer.payment-pass-provisioning</key>
<true/>
<key>com.apple.developer.pass-type-identifiers</key>
<array>
<string>$(TeamIdentifierPrefix)*</string>
</array>`
On iOS project, go to Properties -> iOS Bundle Signing -> Aditional Resources -> Custom Entitlements:
According Apple Documentation you need special permission from Apple to submit apps with this key enabled. For more information, contact apple-pay-inquiries#apple.com.

Related

How to enable LightningProviders for GPIO?

I am trying to access the GPIO on my custom SBC using Windows 10 IoT Core. I have discovered that I must use LightningProviders to accomplish this . So I tried to follow this guide to use lightning providers properly.
I used very simple code:
if (LightningProvider.IsLightningEnabled)
{
LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
}
GpioStatus = "Initializing...";
var gpio = GpioController.GetDefault();
if (gpio == null)
{
GpioStatus = "There is no GPIO controller on this device.";
}
else
{
gpio.OpenPin(1).Write(GpioPinValue.High);
GpioStatus = gpio.OpenPin(1).Read().ToString();
}
Where GpioStatus is output text on a UI.
I discovered that if I run the LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider(); line outside of the enabled check, it picks up the GPIO controller and lets me detect how many pins I have and read them (All low). However I can't change the DriveMode or write to the pins without error. The error I get just says to Make sure the LightningProviders are enabled.
This brings me back to the guide I linked at the start. It suggests to enable DMAP drivers using the Device Portal for W10IoT or DMAPUtil.exe. I have tried both. In the Device Portal the area where it should be is just blank. And in the command line trying to use the DMAPUtil.exe only returns that dmaputil.exe is not available on this system.
Therefore I am asking if there is any other way to enable the LightningProviders or if there a way to know if they are incompatible with my board?
Thanks!
UPDATE
Also tried using the devcon.exe commands in the W10IoT Command line.
I am able to locate the Direct memory access controller but when i do devcon.exe enable *PNP0200 it says it is enabled but remains disabled when checked with devcon.exe status *PNP0200
Please confirm if you have added the IOT_DMAP_DRIVER feature in your OEMInput.xml, this feature will add the DMAP driver in the image. If IOT_DMAP_DRIVER is removed from the OEMInput.xml, the Default Driver Controller will be blank in device protal, and dmaputil will be not available on Windows IoT Core. Please see the IoT Core feature list.
Update:
You can download the source of Lighting Provider, and then deploy and debug in your custom image.

xamarin device owner self upgrade only updates manifest, not executables

I have a strange problem. I have a kiosk application (running as device owner, set by dpm) that is attempting to perform a self upgrade from an apk file that has already been downloaded. The file is downloaded correctly and the upgrade appears to work correctly. The application quits, the system gives a notification that the application has been upgraded by the device owner before the application relaunches.
When the application has relaunched, the version number is reporting as the new version, but none of the modified functionality in the app is present. On the initial login form I added a label with the version number hardcoded into it to compare to the version pulled using Xamarin.Essentials.AppInfo.Version.ToString(). The hardcoded version does not update, but the software version shows correctly.
The device is a Samsung Galaxy Tab A.
I have added a toast on exception which is showing no error messages. I have tried changing the PackageInstallMode to InheritExisting, this didn't seem to make any difference.
The method used for the upgrade is here.
public void UpgradeFromLocalFile(string downloadedFile)
{
try
{
if (MainActivity.Instance.CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Permission.Denied)
{
MainActivity.Instance.RequestPermissions(new string[] { Manifest.Permission.WriteExternalStorage }, 0);
}
if (MainActivity.Instance.CheckSelfPermission(Manifest.Permission.ReadExternalStorage) == Permission.Denied)
{
MainActivity.Instance.RequestPermissions(new string[] { Manifest.Permission.ReadExternalStorage }, 0);
}
if (MainActivity.Instance.CheckSelfPermission(Manifest.Permission.InstallPackages) == Permission.Denied)
{
MainActivity.Instance.RequestPermissions(new string[] { Manifest.Permission.InstallPackages }, 0);
}
var installer = MainActivity.Instance.PackageManager.PackageInstaller;
var parameters = new PackageInstaller.SessionParams(PackageInstallMode.FullInstall);
parameters.SetAppPackageName("my.package.name");
var sessionid = installer.CreateSession(parameters);
var session = installer.OpenSession(sessionid);
var fis = File.OpenRead(downloadedFile);
using (var outputstream = session.OpenWrite("my.package.name", 0, -1))
{
fis.CopyTo(outputstream);
session.Fsync(outputstream);
outputstream.Close();
outputstream.Dispose();
fis.Close();
fis.Dispose();
GC.Collect();
}
var pendingIntent = PendingIntent.GetBroadcast(MainActivity.Instance, sessionid, new Intent(Intent.ActionInstallPackage), 0);
session.Commit(pendingIntent.IntentSender);
}
catch(Exception ex)
{
Toast.MakeText(MainActivity.Instance.ApplicationContext, string.Format("Update failed, you may not have full device admin privileges. Error - {0}", ex.ToString()), ToastLength.Long).Show();
}
}
I'd expect the software version to change as well as the actual executable version. Does anyone have any clues as to what I'm doing wrong.
Ok, after much stuffing around and inspecting install logs with logcat, it seems the apk I was generating by deploy is incomplete. I had to set up a keystore to sign my app and then create a complete archive.
Right click the android proj -> archive.. -> Distribute -> Ad Hoc
This allowed me to self update properly.
Phew. Was bashing my head against it for days. Hope this saves someone else some time.

SetUserAlarm Okuma THINC API C#

I am working on an app for an Okuma lathe.
I would like to be able to put the lathe into an alarm state from the app. I am not getting any errors and the app runs on the machine, but it doesn't go into an NC alarm state.
The line before it does change the text of alarmLabel.
I am using alarmLabel for troubleshooting.
Can anyone provide an example of SetUserAlarm in C#?
Does anyone see what is wrong with my code?
alarmLabel.Text = "Alarm ON";
objCMDMachine.SetUserAlarm(
Okuma.CLCMDAPI.Enumerations.UserAlarmEnum.C,
"Test Alarm",
Okuma.CLCMDAPI.Enumerations.UserAlarmSubSystemEnum.All
);
Your example code there looks okay to me.
To successfully generate a machine alarm, the API must have the licensed feature UserAlarm.
(Okuma.Lathe.UserAlarm in the okuma.api.lic license file).
You can confirm that a machine has this option by using the SCOUT library:
UserAlarmLathe = Okuma.Scout.LicenseChecker.License_UserAlarm_L;
if (UserAlarmLathe.Status == Enums.LicenseStatus.Valid)
{
// ...
}
Additionally, the machine on which the API resides must also have the THiNC ALARM option.
If your machine does not have the option, it can be ordered by contacting your Okuma Distributor and asking for option code " :911-0010 - THiNC ALARM "
The presence of this option can be confirmed by checking the Lathe Spec Code NC-B No. 4, Bit 3. You can check this spec code in your application using either THINC API or SCOUT.
Using THINC API:
Okuma.CLDATAPI.DataAPI.CSpec SpecCodeClass = new Okuma.CLDATAPI.DataAPI.CSpec();
bool THiNK_ALARM = SpecCodeClass.GetBSpecCode(4, 3);
if (THiNK_ALARM)
{
// ...
}
Using SCOUT:
if (Okuma.Scout.SpecCode.NCB.MachineSpecCodeFileExists)
{
if (Okuma.Scout.SpecCode.NCB.SpecFileIsValid)
{
bool THiNK_ALARM = Okuma.Scout.SpecCode.NCB.Bit(
Okuma.Scout.Enums.NCBSpecGroup.NCB1MG, 4, 3);
if (THiNK_ALARM)
{
// ...
}
}
}

Google Play Services with Unity - Sign in results in nothing

So I have been recently trying to add Google Play Game Services to a project my buddy and I are working on.
I figured I would start with the sign in, as that is necessary for anything else that we wanted to add like achievements and leaderboards.
Anyway, I have published a closed Alpha to the google play store with my buddies dev and my own dev emails as the testers. I have set up my OAuth2 Client ID, SHA 1, AndroidManifest file, and other Game Services we are hoping for.
I then in Unity included the most recent Google Play Games Plugin (0.9.50), and set up the Resources and Client ID into our project. I of course have my Key and such for a Signed APK for our Closed Alpha test.
I then set up a button for Sign In within our scene, and have my code set up as follows:
void Start ()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.RequestEmail()
.RequestServerAuthCode(false)
.RequestIdToken()
.Build();
//DEBUGGING ONLY
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
// Does nothing either . . . .
Social.Instance.Authenticate((bool success) => { SignInCallback(success); }, false);
}
public void SignIn()
{
_signInNotification.text = "WARMER";
if (!PlayGamesPlatform.Instance.localUser.authenticated)
{
_signInNotification.text = "SIGNING IN";
Social.localUser.Authenticate((bool success) => { SignInCallback(success); });
}
else
{
PlayGamesPlatform.Instance.SignOut();
_signInNotification.text = "OUT";
}
}
private void SignInCallback(bool success)
{
if (success)
{
Debug.Log("(Something) Signed in!");
_signInNotification.text = "Signed In as : " + Social.localUser.userName;
}
else
{
Debug.Log("(Something) Sign-In Failed!");
_signInNotification.text = "Sign-In Failed!";
}
}[/code]
I have some text that lets me know what part of the code was accessed or run. The sign in button calls the SignIn() function, but only the text 'WARMER' is shown. The Social.localUser.Authenticate() function never seems to be called.
I have tried multiple solutions, changes, variations, etc. However when I click the SignIn button, absolutely nothing happens. No error, no warnings, no text saying Sign-In Failed, nothing.
Not quite sure what I am missing, any ideas would be greatly appreciated! :)
One problem I've realized with debugging Google Play Services problems is that the errors that pop up are from a separate activity, since the sign-in prompt is outside the app. You are probably getting an error response, but it's not from your program. Because of this, you might need to disable any filters in your console to see all errors (if you have Android Studio, the logcat should show all responses from a plugged-in device when it's set to No Filters).
In my case, the plugin had an AndroidManifest file (GooglePlayGames/Plugins/Android/GooglePlayGamesManifest.plugin folder) where the APP_ID had a value with a space in front of it. I believe this was an old workaround to convert the value to a string, but now the app required that it was a numeric value, so deleting the space solved my problem.
Hope this helps!
To set up Google Play Game Services we followed the documentation here and it guided us through all the needed steps.
What we found when we couldn't log in is that while testing your application your OAuth 2.0 client ID (on Google API Console > Credentials) should use the SHA-1 Signing-certificate fingerprint key from your Upload certificate and when it's time to publish the SHA-1 key should be from the App signing certificate. Both certificates can be found on your Google Play Console > All applications (choose the correct one) > Release management > App signing.

Call Navigation/Maps/Drive with an Address in WP8.1 Application

I was wondering if it's possible to call the default navigation application within my Windows Phone 8.1 application. I have an address and I would like for the user to press a button and be able to navigate to that address through the default navigation app. If this is possible, how do I do it?
Thanks for your time,
Johan
You can launch turn-by-turn directions apps using the ms-drive-to and ms-walk-to schemes (depending on the type of directions you want) but you first need to get a geocoordinate for the address that you have. Since you're targeting Windows Phone 8.1, you can use the MapLocationFinder class in the Windows.Services.Maps namespace.
string locationName = "Empire State Building";
string address = "350 5th Avenue, New York City, New York 10018";
var locFinderResult = await MapLocationFinder.FindLocationsAsync(
address, new Geopoint(new BasicGeoposition()));
// add error checking here
var geoPos = locFinderResult.Locations[0].Point.Position;
var driveToUri = new Uri(String.Format(
"ms-drive-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}",
geoPos.Latitude,
geoPos.Longitude,
locationName));
Launcher.LaunchUriAsync(driveToUri);
the official solution is:
Uri uri = new Uri("ms-drive-to:?destination.latitude=" + latitude.ToString(CultureInfo.InvariantCulture) +
"&destination.longitude=" + longitude.ToString(CultureInfo.InvariantCulture))
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// Uri launched.
}
else
{
MessageBox.Show("error");
}
But, there is a problem with this solution.
If you use the nokia programs (HERE), it works fine.
if you want to use waze, you have to add origin.latitude and origin.longitude.
in the MSDN page, They said that it is not necessary, but in fact, you have to write it.
I am already not enable to load moovit but if someone has an issue, it'll help me a lot.

Categories