SwiftUI revenue cat subscription restore testing - swiftui

I was wondering is it possible to test subscription renewals? As of now I have implemented revenue cat SDK and subscriptions are working fine, and as I read the documentation, there was mentioned that every iOS app should have renewal option. And then I implemented it. But when I am pressing button to renew subscription, the console throws out purchase info, but the view does not update and the revenue cat sandbox does not show renewal.
This is console log for when renewal is fired:
{
"opaque_value" : "EjH2QlDnFEa62Q/lF+w+pg==",
"original_application_version" : "1.0",
"bundle_id" : "com.ServiceInn",
"sha1_hash" : "1YhyjmPFjoWvFeC2qwmiGFjU3Iw=",
"application_version" : "1",
"creation_date" : "2023-02-19T19:40:25Z",
"in_app_purchases" : [
{
"product_id" : "si_1999_1m",
"quantity" : 1,
"transaction_id" : "2000000280921474",
"is_in_trial_period" : false,
"is_in_intro_offer_period" : false,
"expires_date" : "2023-02-19T18:15:45Z",
"web_order_line_item_id" : 2000000021232569,
"original_purchase_date" : "2023-02-19T18:10:49Z",
"original_transaction_id" : "2000000280921474",
"product_type" : 3,
"purchase_date" : "2023-02-19T18:10:45Z"
},
{
"product_id" : "si_1999_1m",
"quantity" : 1,
"transaction_id" : "2000000280922265",
And the code I use to renew the subscription.
func restorePurchase(completion: #escaping () -> Void){
Purchases.shared.restorePurchases { (customerInfo, error) in
self.subscriptionPaid = customerInfo?.entitlements.all["Full Access"]?.isActive == true
if self.subscriptionPaid{
completion()
}
}
}
In the completion block I just call firestorm function to change data when subscription is paid.
As I have looked around, I don't see any other thing that there is missing, the renewal is called with that function and handled bool state as if it is renewed or not.

Related

How to fix On error Facebook log in result in android

when I click on the button of sign in the window of choosing facebook profile appears ! but once I confirm the the profile the app crashes . And by using logs I figured out that the register call is not successful so I'have a facebook exeception which causes error , how can i find the source error ?
facebookSignInButton.setOnClickListener(View.OnClickListener {
// Login
Log.i(TAG,"CLICKED")
loginManager.logInWithReadPermissions(this, Arrays.asList("public_profile"))
Log.i(TAG,"Permissions")
loginManager.registerCallback(callbackManager,
object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
Log.d(TAG, "Facebook token: " + loginResult.accessToken.token)
startActivity(Intent(applicationContext,MainActivity::class.java))
}
override fun onCancel() {
Log.i(TAG, "Facebook onCancel.")
}
override fun onError(error: FacebookException) {
Log.d(TAG, "Facebook onError.")
// This part is written in run console
}
})
})
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
callbackManager!!.onActivityResult(requestCode, resultCode, data)
Log.i(TAG,"RESULT"+resultCode.toString()) // this retrun -1
Log.i(TAG,"REQUEST"+requestCode.toString())
}
I expect starting a new activity while logging.
After printing the msg error the problem is in the hash key it doesn't match any key stored !
so instead if using line cmnds I just use this code in my on create function and then copy the hash key into your facebook developer app
val packageName = this.getApplicationContext().getPackageName()
val info : PackageInfo = getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
for ( signature in info.signatures) {
var md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
val hashKey = android.util.Base64.encodeToString(md.digest(), 0)
Log.i(TAG,"HADHKEEEY"+hashKey)
}
Log.i(TAG,"NAAAMEE"+packageName)

Ionic / angulfire2 - Query join reference multiple times

I'm building app with Ionic and angulfire2 and I'm trying to join multiple references from firebase by using the object key.
Database looks following:
{
"achievements" : {
"200" : {
"authorId" : "nGSlhjaDRKh8XdrgxcusU0wdiHN2",
"description" : "I did it"
}
},
"challengeAchievements" : {
"100" : {
"200" : true
}
},
"challenges" : {
"100" : {
"name" : "test challenge"
},
"101" : {
"name" : "test challenge 2"
}
},
"users" : {
"nGSlhjaDRKh8XdrgxcusU0wdiHN2" : {
"email" : "user1#test.com"
},
"wBMX8WOHIpM7dEkzj0hM19OPMbs1" : {
"email" : "user2#test.com"
}
}
}
I would like to join all this data together so that from challenges you get achievements, and from achievements you get the user data.
Currently I'm able to get the achievement details, but not the user data. My provider looks like this at the moment:
getChallengeAchievements(challengeKey) {
return this.rtdb.list(`/challengeAchievements/${challengeKey}`)
.map(achievements => achievements.map((achievement) => {
if (achievement.key)
achievement.details = this.getAchievementDetails(achievement.key);
achievement.user = this.getAchievementUserDetails(achievement.details.authorId);
return achievement;
}));
}
getAchievementDetails(achievementKey?: string): Observable<any> {
if (achievementKey)
return this.rtdb.object(`/achievements/${achievementKey}`);
}
getAchievementUserDetails(authorId?: string): Observable<any> {
if (authorId)
return this.rtdb.object(`/users/${authorId}`);
else console.log('Not found');
}
How should I structure the authorId query in this function? If I use static value in
achievement.details.authorId('nGSlhjaDRKh8XdrgxcusU0wdiHN2')
I'm able to receive the data.
Solved it by subscribing to the first join "achievement.details" and obtaining the user data from there.
getChallengeAchievements(challengeKey) {
return this.rtdb.list(`/challengeAchievements/${challengeKey}`)
.map(achievements => achievements.map((achievement) => {
if (achievement.key)
achievement.details = this.getAchievementDetails(achievement.key);
achievement.details.subscribe(
details => {
achievement.user = this.getAchievementUserDetails(details.authorId);
})
return achievement;
}));
}

CouchDB link multiple documents

Is it possible to link multiple documents in one view.
Eg :
{
"_id" : "0b86008d8490abf0b7e4f15f0c6a463b",
"name" : "copenhagen"}
{
"_id" : "8986008d8490abf0b7e4f15f0c6a333b",
"player" : "Mark"
}
{
"_id" : "4b86008d8490abf0b7e4f15f0c6a463c",
"location" : { "uuid" : "0b86008d8490abf0b7e4f15f0c6a463b"},
"player" : { "uuid" : "8986008d8490abf0b7e4f15f0c6a333b"},
"session" : "9876"
}
I want a view to include location document as well as the player document.
View :
"fetchByLocationAndPlayer": {
"map": "function(doc) { if (doc.session) { emit(doc.session, { _id : **doc.location.uuid** }); } }"
}
In the query I use includedocs = true.
How do I emit multiple documents corresponding to multiple keys in one document?
Yes it is possible. Just use two emits instead of one
emit(doc.session, {_id:doc.location.uuid});
emit(doc.session,{_id:doc.player.uuid});
Couch db wiki lists yet another way of doing this by iterating over the array and emitting linked docs one by one.

Timeline item update error

I have a bundle of timelineitems using Mirror API, Now I am trying to change content of a timeline from bundle. But the below error occurs
An error occurred from update timeline : com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Not Found",
"reason" : "notFound"
} ],
"message" : "Not Found"
}
And update method is something like below
public static TimelineItem updateTimelineItem(Credential credential,
String itemId, String newText) {
try {
Mirror.Timeline timeline = getMirror(credential).timeline();
TimelineItem timelineItem = timeline.get(itemId).execute();
timelineItem.setText(newText);
return timeline.update(itemId, timelineItem).execute();
} catch (IOException e) {
System.err.println("\nAn error occurred from update timeline : " + e);
return null;
}
}
First I try to retrieve the timeline item, when I write execute, then the error occurred
Mirror.Timeline timeline = getMirror(credential).timeline();
TimelineItem timelineItem = timeline.get(itemId).execute();
How can I solve it?
It isn't completely clear from the exception you've posted, but it looks like the itemId isn't valid. How are you getting this itemId and can you verify if it is the timeline.get or the timeline.update that is causing the problem?

'concurrency' error from service when trying to save a second task

I'm trying to save two tasks to the same user story. The first request always succeeds, but the second service request always gets this message back in the response:
Concurrency conflict: [Object has been modified since being read for
update in this context] - ConcurrencyConflictException : Modified
since read on update : Object Class : com.f4tech.slm.domain.UserStory
: ObjectID :
I am using the JavaScript SDK to create the task. I do this twice:
Rally.data.ModelFactory.getModel({
type : 'Task',
success : function(task) {
var record = Ext.create(task, {
Name : taskName,
State : 'Defined',
TaskIndex : 1,
WorkProduct : workProductId,
Owner : userIdsTeam[owner],
SyncDevelopmentTasktoAccuRev : accuSync,
Estimate: hours,
TargetDeployment: targetDeployment,
context: {
project:'/project/' + currentProjectId,
projectScopeDown: true
},
});
record.save({
callback : afterSaveNewTaskCallback
});
}
});
Is there anything I can do to get rid of this error and successfully save two tasks?
In addition to Kyle's answer, you can also use the Rally.data.BulkRecordUpdater to have the creates/updates queued for you. http://developer.rallydev.com/apps/2.0p5/doc/#!/api/Rally.data.BulkRecordUpdater
Since your tasks are both attached to the same underlying user story the creates are both trying to lock on it to set the association and that's why the second one fails. You'll need to chain the callbacks together:
Rally.data.ModelFactory.getModel({
type : 'Task',
success : function(taskModel) {
//Create first task
var task1 = Ext.create(taskModel, {
//...fields...
});
task1.save({
callback: function() {
//Create second task
var task2 = Ext.create(taskModel, {
//...fields...
});
task2.save({
callback: afterSaveNewTaskCallback
});
}
});
}
});