'Detection updating interface' in Unity3D Engine for Huawei AppGallery - unity3d

How can I implement 'update interface' when a new app version is released based on Unity3D?
I have received this message from AppGallery review team : "We found that the detection updating interface isn't called in HMS after the app's startup".
The only documents that I have found is for implementing in Android studio in this link : Updating an App

After an app is launched or when a user proactively checks whether there is a later version, call the related API of the HMS Core SDK to check whether there is a later version available on AppGallery. If so, display a pop-up asking the user whether to update the app.
The key steps for achieving this function are as follows:
A user triggers an update check, for example, by launching the app or manually performing the check on the update check page.
The app calls JosApps.getAppUpdateClient to request to initialize the AppUpdateClient instance.
AppUpdateClient client = JosApps.getAppUpdateClient(this);
The HMS Core SDK returns the AppUpdateClient instance of the current app to the app.
The app calls the AppUpdateClient.checkAppUpdate method to request an update check.
public void checkUpdate() {
AppUpdateClient client = JosApps.getAppUpdateClient(this);
client.checkAppUpdate(this, new UpdateCallBack(this));
}
The HMS Core SDK queries the latest app version information on AppGallery.
AppGallery sends the app version information back to the HMS Core SDK.
The HMS Core SDK sends the check result to the app through a callback.
The app checks the ApkUpgradeInfo instance returned by the onUpdateInfo method in the callback result and checks whether an update is available.
private static class UpdateCallBack implements CheckUpdateCallBack {
private WeakReference<MainActivity> weakMainActivity;
private UpdateCallBack(MainActivity apiActivity) {
this.weakMainActivity = new WeakReference<MainActivity>(apiActivity);
}
public void onUpdateInfo(Intent intent) {
if (intent != null) {
MainActivity apiActivity = null;
if (weakMainActivity != null && weakMainActivity.get() != null){
apiActivity = weakMainActivity.get();
}
// Obtain the update status code. Default_value indicates the default return code when status cannot be obtained, which is determined by the app.
int status = intent.getIntExtra(UpdateKey.STATUS, DEFAULT_VALUE);
// Error code. You are advised to record it.
int rtnCode = intent.getIntExtra(UpdateKey.FAIL_CODE, DEFAULT_VALUE);
// Failure information. You are advised to record it.
String rtnMessage = intent.getStringExtra(UpdateKey.FAIL_REASON);
Serializable info = intent.getSerializableExtra(UpdateKey.INFO);
// Check whether the app has an update by checking whether info obtained is of the ApkUpgradeInfo type.
if (info instanceof ApkUpgradeInfo) {
// Call the showUpdateDialog API to display the update pop-up. The demo has an independent button for displaying the pop-up. Therefore, this API is not called here. For details, please refer to the checkUpdatePop() method.
if (apiActivity != null) {
apiActivity.showLog("There is a new update");
apiActivity.apkUpgradeInfo = (ApkUpgradeInfo) info;
}
}
if(apiActivity != null) {
apiActivity.showLog("onUpdateInfo status: " + status + ", rtnCode: " + rtnCode + ", rtnMessage: " + rtnMessage);
}
}
}
}
The app calls the AppUpdateClient.showUpdateDialog method to request to display the update pop-up for the user.
public void checkUpdatePop(boolean forceUpdate) {
AppUpdateClient client = JosApps.getAppUpdateClient(this);
client.showUpdateDialog(this, apkUpgradeInfo, forceUpdate);
Log.i(TAG, "checkUpdatePop success");
}
The HMS Core SDK displays the update pop-up for the user.
The user chooses to update the app on the update confirmation page.
The HMS Core SDK sends a request to AppGallery to download the latest app installation package.
AppGallery returns the app package to the HMS Core SDK. The HMS Core SDK starts to install the app after the download is complete.
For more details, pls kindly check this docs.

Related

Null reference Error on AccessToken.CurrentAccessToken.UserID

Using Unity editor currently to test FB Login. Getting Null reference exception. Will login once if I clear registry of all session details.
Have tried some hotfixes previously found with SDK updates. This is an older sdk as the version of unity the game was written for was 5.3.3
private void initSession() {
Debug.Log("FbManager init session");
string logType = PlayerPrefs.GetString("LoggedType");
if (logType.Equals("Facebook")) {
GameManager.Instance.facebookIDMy =
AccessToken.CurrentAccessToken.UserId;
callApiToGetName();
getMyProfilePicture(GameManager.Instance.facebookIDMy);
LoggedIn = true;
Expect login to persist and be retrieved based on token stored in registry

Facebook unity GetAppLink CallBack does not have target url

I am using Facebook Unity SDK v7.4.0 with FBAndroidSDK/4.8.2 and managed to implement deep link in a unity game for android platform. Clicking on the deep link takes me inside the game. Now I want that when the user enters the game, he has to be rewarded. But the GetAppLink callback does not have target url
Facebook.Unity.FB.GetAppLink(DeepLinkCallback);
void DeepLinkCallback(IAppLinkResult result)
{
if (result != null && !string.IsNullOrEmpty (result.TargetUrl))
{
}
else
{
Debug.Log("result is null");
}
}
I have gone through many links to try solving this.
https://developers.facebook.com/docs/unity/reference/current/FB.GetAppLink
http://answers.unity3d.com/questions/1134007/how-to-get-facebook-game-request-url.html
Deferred deep links always null in android and facebook SDK
Also deep link is enabled in the developer site, also checked if Facebook sdk is initialised properly before getting the callback
I dont know about the targetUrl but to reward the user you just have to check result.url as mentioned in the FB.GetAppLink documentation.
FB.GetAppLink(DeepLinkCallback);
void DeepLinkCallback(IAppLinkResult result) {
if(!String.IsNullOrEmpty(result.Url)) {
var index = (new Uri(result.Url)).Query.IndexOf("request_ids");
if(index != -1) {
**// ...have the user interact with the friend who sent the request,
// perhaps by showing them the gift they were given, taking them
// to their turn in the game with that friend, etc.**
}
}
}
To send custom data through a Facebook app request, you need to add that data — for example details of your gift — in the FB.AppRequest as mentioned in its documentation.
You need to get the last request id from the URL in the deep link call back and then call Facebook API to get your gift data out of it.
FB.API ("/" + recievedRequestId, HttpMethod.GET, CallbackFunction);
result.url will be null if you haven't added a scheme in Facebook SDK's unity settings.
com.example.appname is probably what you are looking to add.

Issue with register device in MFP8.0

We are developing ionic app with mfp8.0. We have tried to register our device for push notification by using the following code,
function isPushSupported() {
MFPPush.isPushSupported(
function(successResponse) {
alert("Push Supported: " + successResponse);
registerDevice();
}, function(failureResponse) {
alert("Failed to get push support status");
}
);
}
function registerDevice() {
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
MFPPush.registerDevice(
null,
function(successResponse) {
alert("Successfully registered");
},
function(failureResponse) {
alert("Failed to register device:" + JSON.stringify(failureResponse));
}
)
);
}
Not able to register the device now. While getting inside the registerDevice() function App is getting stopped.
Actually, We are getting this error recently. Before that the same code was working fine for us.
I have referred the documentation. But, I am not getting the solution.Link which I have reffered is,
https://github.com/MobileFirst-Platform-Developer-Center/PushNotificationsCordova/blob/release80/www/js/index.js
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/
Note:
GCM recommeded to make use of FCM now, refer the following link,
https://developers.google.com/cloud-messaging/
Actually, after register my device with FCM credentails only I am facing the issue.
Anyone help will be Appreciated!!!
Please make sure you are following the correct instructions. The instructions are layed out in the following page: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/
Visit the Firebase Console.
Create a new project and provide a project name.
Click on the Settings "cog wheel" icon and select Project settings.
Click the Cloud Messaging tab to generate a Server API Key and a Sender ID. and click Save.

Parse Configuration in Android with Smartface App Studio

I am trying to config Parse plug-in into my android app with Smartface App Studio. I followed the link http://www.smartface.io/developer/guides/advanced/push-notification-on-parse-services/#before450 with Smartface App Studio 4.5 version.
But, the device is not getting registered with parse and even not getting any fail message.
Can any one help on this. Thanks in advance.
You are using Smartface 450, so the document you should check is this one below:
http://www.smartface.io/developer/guides/advanced/push-notification-on-parse-services/#after450
You can use the below code on Global.Smartface.js in order to see if it registered or not:
alert("Registration is successful : \n" + Parse.getToken("Landroid/app/Activity;"));
And in Page1.onShow, you can use parse methods as below:
Parse.onRegistrationFail = function () {
alert("Parse Registration failed");
};
// if the application is open and receives notification
Parse.onParsePushReceive = function () {
alert("app opened : \n\n" + Parse.getData());
};
//if the application is closed and get opened by a parse notification
if (Parse.openedByParseNotification()) {
alert("app opened by a notification : \n\n" + Parse.getData());
}

Facebook UNITY SDK login issue

I just installed the new version of Unity 4.3 and the new facebook sdk and I can't get it working.
I created the app on facebook, copied over the app id to the unity facebook settings as required and copied the Package Name and Class name back to facebook.
Because the Android Key Hash is empty ( even it shouldn't be ) I used the methods posted by others to create one with openssl. I created it and copied over to facebook as required.
After this I created a small script to be able to login.
// Use this for initialization
void Start () {
enabled = false;
FB.Init(SetInit, OnHideUnity);
}
// Update is called once per frame
void Update () {
}
private void SetInit()
{
FbDebug.Log("SetInit");
enabled = true; // "enabled" is a property inherited from MonoBehaviour
if (FB.IsLoggedIn)
{
FbDebug.Log("Already logged in");
OnLoggedIn();
}
}
private void OnHideUnity(bool isGameShown)
{
FbDebug.Log("OnHideUnity");
if (!isGameShown)
{
// pause the game - we will need to hide
Time.timeScale = 0;
}
else
{
// start the game back up - we're getting focus again
Time.timeScale = 1;
}
}
void OnGUI(){
if (!FB.IsLoggedIn)
{
if (GUI.Button(new Rect(179 , 11, 287, 160), "Login to Facebook"))
{
FB.Login("email", LoginCallback);
}
}
}
void LoginCallback(FBResult result)
{
FbDebug.Log("LoginCallback");
Debug.Log("LoginCallback");
if (FB.IsLoggedIn)
{
OnLoggedIn();
}
}
void OnLoggedIn()
{
FbDebug.Log("Logged in. ID: " + FB.UserId);
}
Now when I click on the login button a Facebook window appears requesting permission, after I press ok, it returns, but I'm still not logged in... Can anybody help why is this?
Another strange thing I observed that the LoginCallback gets called as soon as I click on the login button, even though I would think it should only when I gave permission. Anyway when I give permission it returns to my app and nothing happens. I can click on the login button again and same thing happens, login callback called, it asks for permisions, I give the permision and returns back, nothing happened. Can anybody help?
Version 4.3.6 of the sdk should fix this problem. It's available here: https://developers.facebook.com/ We are still waiting for it to be approved on the asset store, so the only place to get it right now is from Facebook's site.
Note - it's still broken (5/2014) IF you use a Mac. Just follow the "Rafael solution", discover your hash properly from public void OnLoginComplete(string message). Cheers
So after being frustrated for a few days with having to trace out the key to my phone, I decided to look into what it was doing.
After some research it turned out that when you published to an android device, facebook would use the keystore that was defined in your publish settings, not your .android/debug.keystore file. So I went in and changed the sdk to make it work the proper way. Essentially I changed the SDK to look at the ProjectSettings instead of the debug directory for grabbing the key hash. In the FacebookAndroidUtils.cs I added the following.
// Using the user defined keystore values instead of the debug one.
degbugKeyHash = GetKeyHash( PlayerSettings.Android.keyaliasName, PlayerSettings.Android.keystoreName, PlayerSettings.Android.keyaliasPass, PlayerSettings.Android.keystorePass );
I created a small repo that provides the fix as well as some gui changes to make it more easy to update the key hash.
Github Facebook Unity SDK 6.1 Fix
Update - Fixed a bug with OS X related to escaping spaces on the string path
Hope this helps!
Take the "email" permission out of the login function and try it. Oops I thought I seen the "publish_actions" permission in there too.
Make sure the loginactivity in the manifest is in portrait.
Instead of implementing everything yourself, try using the free and open source SOOMLA Profile plugin for all of your social network needs:
https://github.com/soomla/unity3d-profile
Also available on the asset store for download:
https://www.assetstore.unity3d.com/en/#!/content/24601
It covers Facebook, Twitter and Google+ and has a unified API for logging in, posting statues, uploading images and getting friends lists. For proper disclosure, I'm one of the founders.