Skip to content

Instantly share code, notes, and snippets.

View salihgueler's full-sized avatar
🖖
Aloha

Muhammed Salih Guler salihgueler

🖖
Aloha
View GitHub Profile
@salihgueler
salihgueler / custom_policies.json
Created August 31, 2023 10:43
Custom Policies
[
{
"Effect": "Allow",
"Action": [
"mobiletargeting:GetCampaigns",
"mobiletargeting:CreateCampaign",
"mobiletargeting:SendMessages"
],
"Resource": [
"<Generated-ARN>"
@salihgueler
salihgueler / lambda_for_push_notifications.js
Created August 31, 2023 10:42
lambda_for_push_notifications
const { PinpointClient, CreateCampaignCommand } = require("@aws-sdk/client-pinpoint");
const pinpointClient = new PinpointClient({ region: "eu-central-1" });
/*
* @type { import('@types/aws-lambda').APIGatewayProxyHandler }
*/
exports.handler = async (event) => {
console.log(`EVENT: ${JSON.stringify(event)}`);
final session = await Amplify.Auth.fetchAuthSession() as CognitoAuthSession;
final userTokenResult = session.userPoolTokensResult.type;
switch (userTokenResult) {
case AuthSuccessResult(value: final tokens):
safePrint('Successfully fetched the tokens: $tokens');
case AuthErrorResult(:final exception):
safePrint('Failed to fetch the tokens: $exception');
}
@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: 100,
child:
BlocBuilder<PreviousGroceryDetailsCubit, PreviousGroceryDetailsState>(
bloc: previousGroceryDetailsCubit,
builder: (context, state) {
if (state is PreviousGroceryDetailsSuccess) {
return CachedNetworkImage(
void main() {
printUserAttributes();
}
Future<void> printUserAttributes() async {
try {
final attributes = await Amplify.Auth.fetchUserAttributes();
safePrint('User attributes: $attributes');
} on AuthException catch (e) {
switch (e) {
Future<void> main() async {
final user = await getCurrentUsernameAndEmailWithNamedParameters();
print('Username is ${user.username}');
print('Email is ${user.email}');
final anotherUser = await getCurrentUsernameAndEmailWithNamedParameters();
print('Username is ${anotherUser.$1}');
print('Email is ${anotherUser.$2}');
}
void main() {
final names = ['Salih', 'Abdallah', 'Mo'];
final [best, alsoBest, anotherBest] = names;
print('best $best');
print('alsoBest $alsoBest');
print('anotherBest $anotherBest');
}
void main() {
const friends = [
Friend('Salih', 'D\'artagnan', 'Guler'),
Friend('Abdallah', 'Solution', 'Shaban'),
Friend('Mo', 'Wise', 'Malaka')
];
for (final Friend(:name, :nickname, :surname) in friends) {
print('$name the $nickname $surname!');
}
Future<void> main() async {
final user = await getCurrentUsernameAndEmailWithNamedParameters();
print('Username is ${user.username}');
print('Email is ${user.email}');
final anotherUser = await getCurrentUsernameAndEmailWithNamedParameters();
print('Username is ${anotherUser.$1}');
print('Email is ${anotherUser.$2}');
}
final session = await Amplify.Auth.fetchAuthSession() as CognitoAuthSession;
final userTokenResult = session.userPoolTokensResult.type;
final result = switch (userTokenResult) {
AWSResultType.success => 'Successfully fetched the identityId',
AWSResultType.error => 'Failed to fetch the identityId'
};
safePrint(result);